Common usage of the is () function in jQuery, jqueryis

Source: Internet
Author: User

Common usage of the is () function in jQuery, jqueryis

Checks the Matching Element Set Based on the selector, DOM element, or jQuery object. If at least one element matches the given expression, true is returned.

If no element matches, or the expression is invalid, 'false' is returned '. '''Note: ''' only supports all expressions in jQuery 1.3. In previous versions, if a complex expression is provided, such as a hierarchical selector (for example, + ,~ And>), always returns true

Instance:

$ (Document ). ready (function () {$ ('# faq '). find ('dd '). hide (). end (). find ('dt '). click (function () {// end () is the end of the previous processing function, return to the initial element // explanation: end the hide () of find (dd) with end (), and apply find (dt) to the first # fap var answer =$ (this ). next (); // next () can be added to the next element of this element. next () indicates the next element, and so on if (answer. is (': visable') {// If ANSWER is visible, visible indicates visible, and its usage also includes: hidden (hidden),: first (first ),: last (last) answer. slideUp (); // hide} else {answer. slideDown (); // display }});});

Answer. is (': visable') refers to the visible answer element.
If it is visible, call answer. slideUp (); to hide it.
Else is an invisible element. Call answer. slideDown (); to display it.
Similar works include answer. is (': first') answer. is (': last') and so on, similarCssA: hover


JQuery is usage

The difference is that the writing method is relatively simple, and the traditional method is to make such judgments.
Return document. getElementById ('id'). style. display = "none" you can see jquery in the jquery.xiamiz.com tutorial or Xiami webmaster.


How does jquery call performance functions?

If it appears, you will see the ghost. You wrote the tt1 () function on the homepage.
$ (Document ). in ready (function () {}); the function is scoped and cannot be accessed outside. When onclick is called, an error is reported on the page and tt1 () is not defined. At this time, the binding of jquery events is required. Add an ID for the button, such as id = "btn ";
Write the code like this
$ ("# Btn"). click (function () {$ ("# tp"). fadeIn ();});
Homepage # tp is hidden. It can be displayed only when hidden. Or
$ ("# Btn"). click (function () {$ ("# tp"). hide (). fadeIn ();});
Hide it first and then emerge.


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.