1. Home
  2. Computer Science MCQs
  3. Jquery
  4. What is the purpose of the attr() function in jQuery?

Added 30 Jan 2024

What is the purpose of the attr() function in jQuery?

  1. Adds a class to an element
  2. Gets the value of an attribute for the first element Correct answer
  3. Sets the HTML content of an element
  4. Animates the CSS properties of an element

Correct answer

B. Gets the value of an attribute for the first element

16 views

MCQSEXAM

Explanation

attr() is used to get the value of an attribute for the first element in the set of matched elements.

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