Q
What is the purpose of the attr() method in jQuery?

Answer & Solution

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

What is the purpose of the each() method in jQuery?

A). To filter elements based on a selector

B). To loop through elements and perform a function on each

C). To remove elements from the DOM

D). To add event listeners to elements

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

A). By using the document.onload event

B). By embedding the jQuery code directly into the HTML document

C). By using the jQuery.ready() method

D). By using the window.onload event

Which jQuery method is used to hide an element?

A). remove()

B). hide()

C). display()

D). show()

Which jQuery method is used to perform AJAX requests?

A). get()

B). ajax()

C). post()

D). load()

Which of the following is a valid jQuery selector?

A). $('div > p')

B). $('div ~ p')

C). $('div p')

D). $('div + p')

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

A). To loop through elements

B). To handle events on elements

C). To create animations

D). To perform AJAX requests

What is the syntax for selecting an element by its ID in jQuery?

A). getElementById('elementID')

B). document.getElementById('elementID')

C). $('#elementID')

D). $('.elementID')

What is the purpose of the css() method in jQuery?

A). To toggle CSS properties of elements

B). To get or set CSS properties of elements

C). To remove CSS classes from elements

D). To add CSS classes to elements

What is the purpose of the fadeIn() method in jQuery?

A). To slide up an element

B). To fade in an element

C). To fade out an element

D). To slide down an element

Which of the following is a benefit of using jQuery in web development?

A). Server-side processing

B). Cross-browser compatibility

C). Hardware acceleration

D). Database management