1.

What is the $() function in the jQuery library?

Answer»

  • The $() function is used to access the properties of elements in the DOM (Document Object Model). $() is similar to javascript’s selector functions, but it is more powerful and has more options.

  • $() can be used to access attributes, classes, id, data-* attributes, and more.


  • Example - Suppose you want to change the colour of all the heading1 (h1) to green, then you can do this with the help of jQuery as -

$(document).ready(function() {
$("h1").css("background-color", "green");
});


Discussion

No Comment Found