Replace content of jquery object - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:replaceWith

Description

Replace content of jquery object

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-2.0.2.js"></script> 
      <script type="text/javascript">
    $(function(){/*from   w  w  w  .  j av  a2  s  .co  m*/
var data=$("div").find(".c").replaceWith(function(_,elem){
return "<ul>"+elem+"</ul>";
});
console.log(data);
    });

      </script> 
   </head> 
   <body> 
      <div>
         <div class="c">
            TEST
         </div>
      </div>  
   </body>
</html>

Related Tutorials