Monday, December 25, 2017

jQuery - Day 27


jQuery is a JavaScript library. As like Bootstrap for CSS. Many lines of code in JavaScript is replaced by less amount of jQuery code.

jQuery can be used by downloading as package or online CDN.

<script src="jquery-3.2.1.min.js"></script>  

Features of jQuery Library
  1. HTML / DOM Manipulation
  2. CSS Manipulation
  3. HTML event methods
  4. Effects & Methods
  5. AJAX
  6. Utilities

jQuery Syntax

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".


 $(document).ready(function(){

   // jQuery methods go here...

}); 


 The code inside document. ready(function) will prevent the code from loading before the page loads fully. This will make a good site.

No comments:

Post a Comment