1. What is Jquery?
jQuery is a JavaScript library which has a wide range of actions such as event handling, animation, HTML document traversing, and AJAX interaction for web development. jQuery simplifies JavaScript programming.
The document ready event executes already when the HTML-Document is loaded and the DOM is ready, even if all the graphics are not loaded yet.
jQuery provides a simple way to select single element or group of elements. You can access element by type (
jQuery provides three methods to show or hide elements in sliding behavior.
jQuery is a JavaScript library which has a wide range of actions such as event handling, animation, HTML document traversing, and AJAX interaction for web development. jQuery simplifies JavaScript programming.
2. $(document).ready Method
$(document).ready(function() {
alert("document is ready");
});
3. Selectors
div, span, p), id, CSS class and attribute, etc. I have explained the basic selectors here. You can find some other selectors in the attached project with examples.| jQuery | Example Code | Description |
$('element') | $('blockquote').css('color','red'); | It selects all elements with the given tag name. In this example, it will return all <blockquote> elements in the document. |
$('#id') | $('#item1').css('color','red'); | It selects single element with the given id. If more than one element has been assigned the same id, first match result will be returned. |
$('.class') | $('.myCss').css('color','red'); | It selects all the elements with given class. |
4. Sliding Effect
SlideDown(speed, callback): This method gradually increases the height of the elements, from hidden to visible.SlideUp(speed, callback): This method gradually decreases the height of the elements, from visible to hidden.SlideToggle(speed, callback): This method toggles betweenSildeUp()andSlideDown()for selected elements.
Speed" and "callback" parameters. The Speed parameter can have the following values: - slow
- normal
- fast
- milliseconds, e.g., 100, 500, 1000, etc.