Javascript examples for jQuery Method and Property:prevAll
Get all sibling elements of paragraph
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").prevAll().css("background-color", "yellow"); });//from www . j a v a 2s .co m </script> </head> <body> <p>This is a p element.</p> <div>This is a div element (next sibling of p).</div> <p>This is a p element (next sibling of p).</p> <h4>This is a h4 element (next sibling of p).</h4> <h5>This is a h5 element (next sibling of p).</h5> <span>This is a span element (next sibling of p).</span> <p>This is a p element (next sibling of p).</p> </body> </html>