Javascript examples for jQuery Method and Property:prepend
jQuery .prepend() usage
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.4.4.min.js"></script> <script type="text/javascript"> $(window).load(function(){/*ww w . j ava 2 s . c o m*/ var myString = '<div class="lorem">LOREM<div id="temp" class="ipsum">IPSUM</div></div>'; $('a').click(function() { $('#mydiv').prepend(myString); }); }); </script> </head> <body> <a href="#">Insert</a> <div id="mydiv"></div> </body> </html>