Q
What does the .attr() method do in jQuery?

Answer & Solution

Answer: Option B
Solution:
<p>The .attr() method in jQuery is used to get or set attributes of elements.
Related Questions on Average

How do you select an element with ID 'example' using jQuery?

A). $('example')

B). $('#example')

C). $('.example')

D). document.getElementById('example')

How can you execute jQuery code after the DOM is fully loaded?

A). document.onload

B). Embedding jQuery code

C). jQuery.ready()

D). window.onload

Which function is used to execute code when the DOM is fully loaded in jQuery?

A). execute()

B). ready()

C). load()

D). complete()

What is the purpose of the .on() method in jQuery?

A). Loop through elements

B). Handle events

C). Create animations

D). Perform AJAX requests

What does the $ sign represent in jQuery syntax?

A). Variable name

B). Define a function

C). jQuery object

D). Comment

What is jQuery?

A). JavaScript framework

B). Programming language

C). Markup language

D). Database language

Which of the following is true about jQuery selectors?

A). Select by tag name

B). Cannot select by ID

C). Can select by various criteria

D). Limited to selecting parent elements

What is the purpose of the .addClass() method in jQuery?

A). Remove a class

B). Add a class

C). Toggle a class

D). Hide an element

How can you animate an element's width using jQuery?

A). $('#element').animate({width: '+=100px'})

B). $('#element').animate({width: '100px'})

C). $('#element').width('100px')

D). $('#element').style

Which jQuery method is used to select elements by their class name?

A). selectByClass()

B). getElementByClass()

C). querySelector()

D). $('.className')