jQuery element + next Selector

jQueryWeb DevelopmentFront End Technology

The element +next selector in jQuery is used to select the "next" element of the specified "element".


The syntax is as follows −

("ele + next")

Above, ele is any valid selector, whereas the next parameter is used to specify the element that should be the next element of the element parameter


Let us now see an example to implement the jQuery element +next selector 

 Live Demo

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
      $("div + p").css("color", "orange");
div {
   border:1px solid black;
<h2>Demo Heading</h2>
<p>This is demo text.</p>
<span>span outside p element</span>
<p>This is demo text.</p>
<p>p next to div.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text. <span>span inside p element.</span></p>
<p>This is demo text.</p>


This will produce the following output −

Published on 30-Dec-2019 09:47:46