---
title: "Select next sibling of any tag using jQuery"  
description: "Select next sibling of any tag using jQuery"  
author: "Ethan Karla"  
published: 2021-07-28  
updated: 2023-06-14  
canonical: https://www.mindstick.com/forum/156664/select-next-sibling-of-any-tag-using-jquery  
category: "jquery"  
tags: ["jquery"]  
reading_time: 2 minutes  

---

# Select next sibling of any tag using jQuery

How to [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) next sibling of any tag using jQuery?

## Replies

### Reply by Aryan Kumar

Sure, here is how you can select the next sibling of any tag using jQuery:

Code snippet

```plaintext
// Select the element with the id "myElement"
var element = $("#myElement");

// Get the next sibling of the element
var nextSibling = element.next();

// Do something with the next sibling
nextSibling.css("color", "red");
```

The next() method returns a jQuery object that contains the next sibling of the selected element. This jQuery object can then be used to perform any actions that you would like on the next sibling.

In the example above, we are using the css() method to set the color of the next sibling to red. However, you could also use the text() method to get the text of the next sibling, or the click() method to add a click event handler to the next sibling.

The next() method can also be used to select multiple next siblings. For example, the following code will select all of the next siblings of the element with the id "myElement":

Code snippet

```plaintext
var nextSiblings = $("#myElement").nextAll();
```

The nextAll() method returns a jQuery object that contains all of the next siblings of the selected element. This jQuery object can then be used to perform any actions that you would like on all of the next siblings.


---

Original Source: https://www.mindstick.com/forum/156664/select-next-sibling-of-any-tag-using-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
