What is the purpose of the attr() function in jQuery?
-
A
Adds a class to an element
-
B
Gets the value of an attribute for the first element
Correct answer
-
C
Sets the HTML content of an element
-
D
Animates the CSS properties of an element
Correct answer
B. Gets the value of an attribute for the first element
16 views
Explanation
attr() is used to get the value of an attribute for the first element in the set of matched elements.
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ