jquery is() method


  Translation results:

is

英[ɪz]  美[ɪz]  

vt.& vi. is (the third single form of be)

n .exist

jquery is() methodsyntax

Function: is() detects a set of matching elements based on a selector, element, or jQuery object, and returns true if at least one of these elements matches the given parameters.

Syntax: .is(selector)

Parameters:

ParameterDescription
selector String value, containing the selector expression of the matching element.

Note: Unlike other filtering methods, .is() does not create a new jQuery object. Instead, it allows us to instrument the jQuery object without modifying its contents. This is often useful inside callbacks, such as event handlers.

jquery is() methodexample

<!DOCTYPE html>
<html>
<head>
  <style>div { color:red; }</style>
  <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
</head>

<body>
  <form><p><input type="checkbox" /></p></form>
  <div></div>

<script>
  var isFormParent = $("input[type='checkbox']").parent().is("form");
  $("div").text("isFormParent = " + isFormParent);
</script>

</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A