jQuery is a JavaScript library.
The purpose of jQuery is to make it much easier to use JavaScript on the website.
jQuery syntax is tailor made for selecting HTML elements and performing some action on the element
ex-
$(“selector”).action()
. A $ sign to define/access jQuery
. A (selector) to query (or find) HTML page
. A jQuery action() to be perform need an elements
$(this).hide() – hides the current element .
$(“p”).hide()- hides all the <p> elements .
$(“.test”).hide()- hides all elements with class =”test” .
$(“#test”).hide()- hides all elements with id =”test” .
The Document Ready Event
$(document).ready(function)
{
// jQuery methods go here
}
This is to prevent any jQuery code from running before the document is finshied loading is ready.
$(document).ready(function()
{
$(“button”).click(function()
{
$(“p”).hide();
});
});