Ways to start using jQuery on web site, we can:
- Download the jQuery library from jQuery.com (download and put in resource) eg.:
<head>
<script src="jquery-3.5.1.min.js"></script>
</head>
- Include jQuery from a CDN, like Google (eg.
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
jQuery Syntax
The jQuery syntax is tailor-made for selecting HTML elements and perform some action on the element(s).
Basic syntax is: $(selector).action()
- A $ sign to define/access jQuery
- A (selector) to "query (or find)" HTML elements
- A jQuery action() to be performed on the element(s)
Examples:
$(this).hide() - hides the current element.
$("p").hide() - hides all <p> elements.
$(".test").hide() - hides all elements with class="test".
$("#test").hide() - hides the element with id="test".
Comments
Post a Comment