jQuery Selector element + next select <div> after <ul>

Description

jQuery Selector element + next select <div> after <ul>

View in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("ul + div").css("background-color", "yellow");
});/*from   www. j a  v a2s . c  o m*/
</script>
</head>
<body>

<ul>
  <li>List item</li>
</ul>

<div>This is a div element that is next to an ul element</div>
<p>This is a paragraph (not a div)</p>
<div>This is another div element</div>

<ul>
  <li>List item</li>
</ul>

<div>This is also a div element that is next to an ul element</div>
<p>This is another paragraph (not a div)</p>
<div>This is another div element</div>

</body>
</html>



PreviousNext

Related