1. Home
  2. Computer Science MCQs
  3. Jquery
  4. How do you select all elements with a specific class in…

Added 30 Jan 2024

How do you select all elements with a specific class in jQuery?

  1. selectByClass()
  2. $(".classname") Correct answer
  3. #classname
  4. .classname{}

Correct answer

B. $(".classname")

16 views

MCQSEXAM

Explanation

$(".classname") selects all elements with that class: the dot marks a class selector and $() is the jQuery function that runs it.

# would select by ID, and .classname{} is CSS rule syntax, not a jQuery call.

For more solved questions like this one, see Computer Science MCQs on MCQsExam.com.

Reference

https://www.w3schools.com/jquery/default.asp

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Jquery MCQs

Practise all Jquery MCQs

Similar MCQs