Horje Website
Selecting Elements that Contain Specific Child Elements in jQuery – Learn Select elements that has certain child elements – jQuery Code

Selecting Elements that Contain Specific Child Elements in jQuery – Learn Select elements that has certain child elements

Selecting Elements that Contain Specific Child Elements in jQuery - Learn Select elements that has certain child elements - jQuery Code


 
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Selecting Elements that Contain Specific Child Elements in jQuery</title>
  6. <style>
  7. .highlight{
  8. background: yellow;
  9. }
  10. </style>
  11. <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
  12. <script>
  13. $(document).ready(function(){
  14. $("ul li").has("ul").addClass("highlight");
  15. });
  16. </script>
  17. </head>
  18. <body>
  19. <ul>
  20. <li>Section 1</li>
  21. <li>Section 2</li>
  22. <li>
  23. <ul>
  24. <li>Section 2.1</li>
  25. <li>Section 2.2</li>
  26. <li>Section 2.3</li>
  27. </ul>
  28. </li>
  29. <li>Section 4</li>
  30. </ul>
  31. </body>
  32. </html>



Try Your Self ->



Published:
September 16, 2020
Author:
admin
Category:
jQuery Advanced, jQuery Source Code
Views:
23

This article was posted in jQuery Advanced, jQuery Source Code and tagged , , . Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Horje © 2011 - 2023