---
title: "Use of is() method in jQuery"  
description: "Use of is() method in jQuery"  
author: "Ethan Karla"  
published: 2021-07-28  
updated: 2023-11-28  
canonical: https://www.mindstick.com/forum/156642/use-of-is-method-in-jquery  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# Use of is() method in jQuery

What is the use of is() [method in jQuery](https://www.mindstick.com/forum/156655/trim-method-in-jquery)? How is it different from jQuery?

## Replies

### Reply by Aryan Kumar

\
In jQuery, the **is()** [method](https://www.mindstick.com/forum/166/webservice-method) is used to check if an element matches a specified selector, element, or set of elements. It returns **true** if the element matches the specified criteria and **false** otherwise. Here's a simple example:

Let's say you have a button, and you want to check if it has a specific class, let's call it "highlight".

```plaintext
// Check if the button has the class "highlight"
if ($('#your-button-id').is('.highlight')) {
    // If true, do something
    console.log('The button has the "highlight" class.');
} else {
    // If false, do something else
    console.log('The button does not have the "highlight" class.');
}
```

In this example, the **is('.highlight')** part checks whether the button with the specified ID has the class "highlight" or not. You can customize the criteria inside the **is()** method based on your specific needs, such as checking for other selectors or elements.


---

Original Source: https://www.mindstick.com/forum/156642/use-of-is-method-in-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
