jQuery .is() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Traversing

Definition

.is() (since jQuery 1.0) checks whether at least one element in the current set matches a selector, callback, jQuery object, or DOM element. It returns true or false — perfect for if checks and event handlers.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("#box").is(".active")          // true / false
$(event.target).is("li")         // click was on an <li>?
$("input").parent().is("form")   // official parent check

// Since 1.6:
$el.is(function () { … })        // callback test
$el.is($other)                   // overlap with a jQuery set?
$el.is(domNode)                  // same DOM element?

// Not a filter — returns boolean, not a new set
CallWhat it does
jQuery setElements to test
selectorSince 1.0 — CSS/jQuery selector
functionSince 1.6 — return true to match
jQuery / ElementSince 1.6 — compare against nodes
Return valueBoolean only

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Select elements ($("#box"), $(event.target), …).
Step 2Pass a selector, callback (1.6+), jQuery object, or DOM element.
Step 3Read the boolean — true if any element matches.

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

Example 1 — Selector Test

Ask whether an element matches a class or tag.

jQuery
$("#out").text(
  "is .active? " + $("#box").is(".active") + "\n" +
  "is div? " + $("#box").is("div")
);
Try It Yourself

How It Works

  1. Select. $("#box") is the element to test.
  2. Class. .is(".active") asks if it has that class.
  3. Tag. .is("div") asks if it is a div.

Example 2 — Event Target (Official)

Only react when the click landed on an li itself — not a child.

jQuery
$("ul").on("click", function (event) {
  var target = $(event.target);
  if (target.is("li")) {
    $("#out").text("Clicked li: " + target.text());
  } else {
    $("#out").text("Clicked a child — ignored");
  }
});
Try It Yourself

How It Works

  1. Bubble. Clicks on children still reach the ul handler.
  2. Target. event.target is the real clicked node.
  3. Test. .is("li") is true only for the list item itself.

Example 3 — Official Parent Check

Is the checkbox’s immediate parent a form?

jQuery
var isFormParent = $("input[type='checkbox']").parent().is("form");
$("#out").text("isFormParent = " + isFormParent);
Try It Yourself

How It Works

  1. Find. Select the checkbox.
  2. Parent. Move one level up with .parent().
  3. Test. .is("form") checks that node’s tag.

Frequently Asked Questions

.is() checks whether at least one element in the current jQuery set matches a selector, passes a callback, or matches a jQuery object or DOM element. It returns true or false — not a new jQuery object. Selector form since 1.0; function, selection, and element forms since 1.6.
.filter() returns a new jQuery object with matching elements. .is() returns a boolean — true if any element matches. Use .filter() to keep matches; use .is() inside if checks.
No. It only tests the current set and returns true/false. The original collection is unchanged — ideal in event handlers and conditionals.
When at least one element in the set satisfies the argument. An empty jQuery object always returns false.
Yes, since jQuery 1.6. .is(function(index, element) { … }) runs for each element. If any call returns true, .is() returns true. Inside the callback, this is the current DOM element.
When clicks bubble from children, $(event.target).is("li") checks whether the clicked node itself is a list item — not a span or strong inside it.

Next: Event Object

Get the last element in the current matched set.

Event Object tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful