wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript (Jquery) Quiz # 2

Total questions: 40

Worksheet time: 25mins

Name
Class
Date
1.

The following is correct syntax for CSS


p { color: red; }

a)

True

b)

False

2.

addClass() - Adds one or more classes to the____________.?

a)

selected classes.

b)

selected elements

c)

None of the above

3.

Which of the following is the correct syntax to Set CSS in JQuery?

a)

$("p").css("background-color="yellow");

b)

$("p").css("backgroundcolor", "yellow");

c)

$("p").css("background-color", "yellow");

4.

In order to make use of jQuery in our HTML page, which of the following lines of code must be put in our page?

a)

<link rel="stylesheet" href="styles/style_anchor.css" type="text/css" />

b)

<meta name="viewport" content="width=device-width, initial-scale=1">

c)

<script src="script/jquery-3.6.0.js"></script>

d)

<script src="script/jquery.slider.min.js"></script>

5.

Given the following command in Javascript, which jQuery code will do the same thing?


document.getElementById("lastname").value

a)

$(".lastname").val()

b)

$("#lastname").val()

c)

$("lastname").val()

6.

Given the following HTML:

<a id="myLink" href="http://www.google.com">Google</a>


What text will the following code display in the alert box?

alert($("#myLink").attr("href"));

(a)  

7.

What will be the output of the following JavaScript code?

a)

true

b)

false

c)

runtime error

d)

logical error

8.
Question 3: Which sign does jQuery use as a shortcut for jQuery?
a)
the $ sign
b)
the ? Sign
c)
the % sign
9.
Question 16: Which jQuery function is used to prevent code from running, before the document is finished loading?
a)
$(document).ready()
b)
$(body).onload()
c)
$(document).load()
10.
Question 18: Which jQuery method is used to switch between adding/removing one or more classes (for CSS) from selected elements?
a)
switchClass()
b)
switch()
c)
toggleClass()
d)
altClass()
11.

What does the following selector: $("div"). will select in jQuery?

a)

All div elements

b)

The first div element

c)

any one div element

d)

The last div element

12.

jQuery is a

a)

JavaScript Language

b)

JavaScript Library

c)

JavaScript Method

d)

JavaScript Class

13.

What is the main purpose of jQuery?

a)

Make CSS easier

b)

Write less, do more

c)

Replace JavaScript completely

d)

Handle server-side operations

14.

Which method changes CSS with jQuery?

a)

.style()

b)

.css()

c)

.design()

d)

.addStyle()

15.

It is an alias of jQuery function.

(a)  

16.

Why was jQuery originally created

a)

To replace HTML

b)

To simplify and speed up JavaScript development

c)

To remove the need for CSS

d)

To build server-side applications

17.

Which of the following is NOT a jQuery feature

a)

DOM manipulation

b)

Event handling

c)

AJAX

d)

Database management

18.

How do I declare a variable named weekDay and set it to "Tuesday"?

a)

weekDay = "Tuesday";

b)

let weekDay = "Tuesday";

c)

const weekDay = "Tuesday";

d)

WeekDay = "Tuesday";

19.

In JavaScript, how would I declare a constant myName?

a)

constant myName = "Michael Phelps";

b)

var myName = "Michael Phelps";

c)

const MyName = "Captain Sparrow";

d)

const myName = "Princess Buttercup";

20.

What are the preferred (modern) coding conventions for declaring variables?

a)

const

b)

var

c)

let

d)

mkdir

21.

The model representing the elements of a web page in a tree structure, created by the browser, is called...

a)

Domain Object Model

b)

HyperText Markup Model

c)

Document Object Model

d)

Domain Oriented Model

22.

Predict the output:


<!DOCTYPE html>

<html>

<body>


<p id="test"></p>


<script>

function firstFunction(p1, p2) {

return p1 + p2;

}

document.getElementById("test").innerHTML = firstFunction(1, 5);

</script>


</body>

</html>

a)

6

b)

No output

c)

Error while declaring the function

d)

None of the above

23.

Which line of html code would you use to add the image 'image.jpg' into index.html?

a)

<img src="image.jpg">

b)

<img href="image.jpg">

c)

<img src="project/images/image.jpg">

d)

<img src="images/image.jpg">

24.

Where a script stores bits of information:

a)

Variables

b)

Identifier

c)

Array

d)

Code blocks

25.

Where a list of values is stored:

a)

Array

b)

Identifier

c)

Code block

d)

Concatenation

26.

Statements end with a ______________, which tells the JavaScript interpreter when a step is over, indicating that it should move to the next step.

a)

semicolon

b)

colon

c)

period

d)

comma

27.

What is the value of "elem" variable?

var elem;
if ( 11 == 11 && 12 < 10 ){
elem = 12;
}else {
elem = 'undefined';
}

a)

undefined

b)

12

c)

11

d)

10

28.

What is displayed on the browser?

function myFunction(){

document.write(myFunction === myFunction);

}

myFunction();

a)

true

b)

false

c)

undefined

d)

null

29.

What is the value of

var fruits = ["A", "D", "F", "B"];

fruits.reverse();

alert(fruits)

a)

A,B,D,F

b)

B,F,D,A

c)

null

d)

undefined

30.
Comparison Operators
What is != ?
a)
Equal to
b)
Equal value and equal type
c)
Not equal
d)
Not equal value or not equal type
31.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

32.

Predict the output of the following JavaScript code snippets.

a)

8

b)

Error

c)

35

d)

"35"

33.

Which of the following is not a valid way to declare a variable in JavaScript?

a)

var x =5;

b)

let y = 10;

c)

const z = 15;

d)

int w = 20;

34.

What will this code display?

a)

570

b)

569

c)

568

d)

attendees

35.

JavaScript : What is the alert display for text3 ?

a)

John Doe

b)

JohnDoe

c)

"John" " " "Doe"

d)

"JohnDoe"

36.

What would this piece of code display?

let x = 5;

console.log(x != 8);

a)

false

b)

x!=8

c)

true

d)

8

37.

The Document Object Model (DOM) can be used to:

a)

Find elements by class

b)

Create new elements

c)

Retrieve data from a server

d)

Change element styles

38.

What will this code display?

a)

8, 2, 1, 4, 7

b)

82147

c)

Myarray.length

d)

5

39.

Which of these is a method?

a)

getElementById( )

b)

style

c)

document

d)

color

40.

What is the "++" operator called ?

a)

Incrementing

b)

Decrementing

c)

Two Additions