Hide/show event functions and JQuery events in jquery

Source: Internet
Author: User

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.