Horje Website
Selecting the Specific Sibling Elements in jQuery – Learn Get specific siblings of an element – jQuery Code

Selecting the Specific Sibling Elements in jQuery – Learn Get specific siblings of an element

Selecting the Specific Sibling Elements in jQuery - Learn Get specific siblings of an element - jQuery Code


 
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Selecting the Specific Sibling 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. $("p").siblings("ul").addClass("highlight");
  15. });
  16. </script>
  17. </head>
  18. <body>
  19. <div class="container">
  20. <h1>Hello World</h1>
  21. <p>This is a <em>simple paragraph</em>.</p>
  22. <ul>
  23. <li>Item One</li>
  24. <li>Item Two</li>
  25. </ul>
  26. </div>
  27. </body>
  28. </html>



Try Your Self ->



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

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 - 2022