Hide/show event functions and JQuery events in jquery
1.
$ ("Button"). click (function () {$ ("p"). hide ();});
2.
If your website contains many pages and you want your jQuery functions to be easy to maintain, put your jQuery functions in an independent. js file. Place the page reference in the head label
- 3
- If a name conflict exists, rename the jQuery library.
JQuery uses noConflict () to solve this problem.
Var jq = jQuery. noConflict () helps you replace the $ symbol with your own name (such as jq.
- Example:
$. NoConflict ();
JQuery (document). ready (function (){
JQuery ("button"). click (function (){
JQuery ("p"). text ("jQuery is still running! ");
});
});
- 4
- $ (Document). ready (function) binds the function to the ready event of the document (when the document is loaded)
- $ (Selector). click (function) triggers or binds a function to a click event of the selected element.
- $ (Selector). dblclick (function) trigger or bind the function to the double-click event of the selected Element
- $ (Selector). focus (function) triggers or binds the function to the get focus event of the selected element.
- $ (Selector). mouseover (function) triggers or binds a function to the mouse hover event of the selected Element
5. Hide and display with speed ,,
$(selector).hide(speed,callback);$(selector).show(speed,callback);
The optional speed parameter specifies the hidden/display speed. The value can be "slow", "fast", or millisecond. The optional callback parameter is the name of the function executed after it is hidden or displayed.
Example:
$ ("Button"). click (function (){
$ ("P"). hide (1000, function (){
Alert ("The paragraph is now hidden ");
});
});
6. Use the toggle () method to switch between the hide () and show () methods.
Show Hidden elements and hide the displayed elements:
Example: $ ("button"). click (function () {$ ("p"). toggle ();});
There is also a Syntax:
$(selector).toggle(speed,callback);