Home
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function () { $(".myCls").before('<span>This is span - Adding before tags whose CSS class is myCls.</span>'); $("footer").before('<p style="color:green">Tag 1 : This is paragraph</p>', '<div style="color:gray">Tag 2 : This is div</div>'); }); </script> </head> <body> <h1>jQuery Manipulation Methods: before()</h1> <div class="myCls"> This is Div </div> <footer> This is a footer tag </footer> </body> </html>
Result: