Insert html element inside another element - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:html

Description

Insert html element inside another element

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){// www. j a v a2s.  c o  m
$('ul.foo li.bar a').wrap('<span class="spanclass">')
    });

      </script> 
 </head> 
 <body> 
  <ul class="foo"> 
   <li class="bar"> <a href="bar.html">Bar Html</a> </li> 
  </ul>  
 </body>
</html>

Related Tutorials