jquery banner

jQuery Multiple Choice Questions (MCQs) and Answers

Master jQuery with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of jQuery concepts. Begin your placement preparation journey now!

Q1

Q1 What does the $ symbol represent in jQuery?

A

$ represents a library function

B

$ is an alias for jQuery

C

$ is a variable

D

$ is an operator

Q2

Q2 Which jQuery method is used to document-ready event?

A

.onDocumentReady()

B

.ready()

C

.load()

D

.documentReady()

Q3

Q3 What is jQuery primarily used for?

A

CSS manipulation

B

Server-side operations

C

HTML document manipulation

D

Networking

Q4

Q4 Is jQuery a library for client-side or server-side scripting?

A

Client-side

B

Server-side

C

Both

D

None

Q5

Q5 How can jQuery be added to a web page?

A

Link to a local copy

B

Link to a CDN

C

Both

D

Neither

Q6

Q6 Which jQuery function is used to select elements by tag name?

A

.getElement()

B

.select()

C

.$()

D

.query()

Q7

Q7 What type of files can be manipulated using jQuery?

A

HTML only

B

CSS only

C

JavaScript only

D

HTML, CSS, and JavaScript

Q8

Q8 Which jQuery method is used to set the text content of an element?

A

.setText()

B

.text()

C

.textContent()

D

.setContent()

Q9

Q9 A jQuery selector doesn't return any elements. What could be the most likely cause?

A

Incorrect selector syntax

B

Elements do not exist

C

jQuery not loaded

D

Script error

Q10

Q10 How do you select all <p> elements within a <div> using jQuery?

A

$('div p')

B

$('div > p')

C

$('div + p')

D

$('div, p')

Q11

Q11 Which selector is used to find elements with a specific class in jQuery?

A

.findClass()

B

.class()

C

.$()

D

$('.className')

Q12

Q12 How do you select an element with an ID of "unique" using jQuery?

A

$('#unique')

B

.getId('unique')

C

.$('unique')

D

.querySelector('#unique')

Q13

Q13 Which jQuery method is used to select elements that are hidden?

A

.hidden()

B

.findHidden()

C

.is(':hidden')

D

$(':hidden')

Q14

Q14 What is the result of the selector $('div:first')?

A

Selects the first div in the document

B

Selects the first div in each section

C

Selects the first child div

D

Selects none of the above

Q15

Q15 How can you select elements with an attribute value starting with "https" in jQuery?

A

$('[href^="https"]')

B

$('[href*="https"]')

C

$('[href$="https"]')

D

$('a[href^="https"]')

Q16

Q16 How do you select all input elements of type checkbox that are checked?

A

$('input[type="checkbox"]:checked')

B

$('checkbox:checked')

C

$('input:checked')

D

$('input[type=checkbox]')

Q17

Q17 What does the selector $('li:odd') select?

A

Every odd li element

B

Every even li element

C

All li elements

D

No li elements

Q18

Q18 How would you hide all elements with the class "hide-me" using jQuery?

A

.hideClass('hide-me')

B

$('.hide-me').hide()

C

hide('.hide-me')

D

$('.hide-me').remove()

Q19

Q19 Which jQuery method removes the selected element from the DOM?

A

.delete()

B

.detach()

C

.remove()

D

.erase()

Q20

Q20 How can you add a new class to selected elements in jQuery?

A

.addClass('newClass')

B

.newClass('newClass')

C

.setClass('newClass')

D

.toggleClass('newClass')

Q21

Q21 What jQuery method is used to get the value of an attribute for the first element in the set of matched elements?

A

.getAttr('attribute')

B

.attribute('attribute')

C

.attr('attribute')

D

.value('attribute')

Q22

Q22 Why might $('.class').hide() not work if the class is correctly specified?

A

Incorrect jQuery version

B

Syntax error in code

C

Class does not exist at runtime

D

jQuery not loaded

Q23

Q23 What could cause the selector $('#id') to return more than one element?

A

Invalid HTML structure

B

Multiple elements with the same ID

C

jQuery bug

D

None of these

Q24

Q24 If $('input').val() returns undefined, what might be the reason?

A

No input elements are present

B

Input is not of type text

C

Input has no value

D

Multiple inputs are present

Q25

Q25 What jQuery method is used to bind a click event to a button?

A

.onClick()

B

.click()

C

.buttonClick()

D

.triggerClick()

Q26

Q26 How do you attach an event handler to elements that may be added dynamically in jQuery?

A

.bind()

B

.on()

C

.live()

D

.delegate()

Q27

Q27 Which method stops the default action of an event?

A

.stop()

B

.preventDefault()

C

.halt()

D

.stopAction()

Q28

Q28 How do you remove an event handler in jQuery?

A

.unbind()

B

.detachEvent()

C

.removeEvent()

D

.off()

Q29

Q29 What method would you use to trigger an event handler of 'submit' event programmatically?

A

.trigger('submit')

B

.invoke('submit')

C

.call('submit')

D

.execute('submit')

Q30

Q30 What does the .stopPropagation() method do?

A

Stops the event from bubbling up the event chain

B

Stops all functions

C

Prevents default actions

D

None of the above

...
ad verticalad vertical
ad