The following is JQuery's Is() method judgment;
$( function(){
$("ul").click(function(event){
var tar = event.target;
if(tar.tagName == "STRONG"){
alert (tar.tagName);
}
});
})
The above is the native JS judgment;
$(function(){
$("ul").click(function(event){
var tar = event.target;
if($(tar).is("strong")){
alert(tar.tagName);
}
});
})
Most of the methods in JQuery return the JQuery diagonal. The Is() method returns a Boolean value;
Difference:
$(tar): Pack the tar object into A jquery object. Only in this way can jquery methods be used; $(tar).is("strong"): Use the Is() method to judge;
Use of is method in jQuery is() is used to detect whether there are matching elements.
Explanation in the help documentation: Use an expression to check the currently selected set of elements, and return true if at least one element matches the given expression.
Of course we know that the above statement is correct. But we can also write like this
alert($("input:checkbox").is(":checked")); //In this way We can judge whether a certain checkbox is selected. And so on. We can use: checked. Can we also use other ones? Of course it is possible. Search the help document for ":". All the types here can be used. Make a judgment
For example, $("input[name=btnClick]").is(":button"); is used to judge whether the control is a button, etc..
The rest is Everyone's own efforts...