JQuery returns the code for determining the Boolean Is () condition.

Source: Internet
Author: User

The following Is JQuery's Is () method judgment;
Copy codeThe Code is as follows:
$ (Function (){
$ ("Ul"). click (function (event ){
Var tar = event.tar get;
If (tar. tagName = "STRONG "){
Alert (tar. tagName );
}
});
})

The above is the native JS judgment;
Copy codeThe Code is as follows:
$ (Function (){
$ ("Ul"). click (function (event ){
Var tar = event.tar get;
If ($ (tar). is ("strong ")){
Alert (tar. tagName );
}
});
})

Most of the methods in JQuery return JQuery diagonal. While the Is () method returns a Boolean value;
Differences:
$ (Tar): wraps a tar object into a jquery object. Only in this way can jquery's method be used; $ (tar ). is ("strong"): it Is determined by the is () method;

Use of the is method in jQuery

Is () is used to detect whether there are matching elements.
Explanation in the help document: use an expression to check the selected element set. If at least one element matches the given expression, true is returned.

We certainly know that the above statement is correct, but we can also write this statement.
Alert ($ ("input: checkbox "). is (": checked"); // you can determine whether a checkbox is selected. and so on. we can use: Can checked be used or another one. of course .. search for ":" In the help document. All types can be used for judgment.

For example, $ ("input [name = btnClick]"). is (": button") is used to determine whether the control is a button, etc ..

The rest is your own efforts ..

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.