The effects method in jquery is used to add effects to a web page. Hence, the effects that can be added to a web page are fading, hiding and showing, animation and sliding. Many different methods can be used to put effects on a web page using jQuery. The effects that can be used are as follows:
show(): The show effect is used to show specific elements on the webpage.
Hide (): The hide method is used to hide specific elements on the webpage. Show and Hide can be used together to create a list that shows or hides on the command of the visitor.
FadeOut (): The fadeout method is used to fade one set of selected elements into the other elements. It can also be used to fade the marked elements into nothingness or become transparent.
Toggle (): the toggle method is used to bring the elements of the hide and show together. So, if you want to hide an element and then show it, you will need to use the toggle in it to bring the desired effect.
FadeIn(): If you wish to fade a specific element into opaqueness, you will need to use the fade-in method in jQuery.
Selectors help find or select an HTML element on a web page that you wish to work with using jQuery. A few basic selectors are:
Name: The simplest selector to use; the name selector helps find and select an element just by using and matching with its given element Name.
Class: The class selector is used when you need to find and select all the elements and match them with the given Class.
Universal (*): If you need to select all the elements that are present in a DOM, the Universal selector is used.
Attribute selector: If you need to select an element based on their attribute value, the attribute selector is used.
#ID: The ID selector only finds and selects with the single element that matches with the given ID.
The Clone method in jQuery is used to make clones of the set of controls. Thus, it copies the set of elements selected and then matches them using the selectors. It copies both the descendant elements and the parent elements.
An example of the clone method is:
$(document).ready(function(){ $('#mycontrolid').click(function(){ $('#mycontrolid').clone().appendTo('body'); return false; }); });
.remove(): The remove () is used to remove an element along with its all child elements. After using the remove, data from DOM can be restored but not from vent handlers.
.empty(): The empty () keeps the element concerned but targets its content and the content of its child elements and removes them.
.detach(): The detach () aims to remove the element along with all its child elements. However, it does not remove the data and the event handlers concerned with those elements.
The advantages are as follows:
.ajaxStart(): This Ajax function is used to register the handler that is needed to be called at the time of the first Ajax request.
.ajaxStop(): This Ajax function is used to register the handler that is needed to be called at the time of the completion of an Ajax request.
.ajaxSuccess(): This Ajax function is used to register the handler that is called at the time of an Ajax request being completed.
$(“#members a”).bind(“click”, function(f){….});
Hence, the event handler will be bound to any of the matching anchors.
$(“#members”).delegate(“ul li a”, “click”, function(f){….});
The $(document).ready(function (), when used in JQuery, ensures that the code inside this given function executes only upon the loading of the full page. Hence, no error will be shown.
The slide toggle method in jQuery is used to give animation effects on a web page to the selected elements. The method is used along with the following parameters:
Speed: The speed parameter is used to specify the speed of the animation effect relating to how fast the slide will toggle on the webpage. This is an optional parameter.
Easing: Easing is again an optional parameter and is used to specify the speed of the toggling of the slide but at different intervals of time during the animated effect.
Callback: The callback parameter is used after the slide toggle method is completed. Hence, upon using the callback parameter, the callback function is accepted and executed. It is also an optional parameter.
The parameters are as follows: