Tryit Editor v1.8

Source Code:
<!DOCTYPE html> <html> <head> <script src="../../ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").prevAll().css("background-color","yellow"); }); </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>
Result:
W3Schools.com - Try it yourself