loop remove only certain child nodes - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:remove

Description

loop remove only certain child nodes

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.4.4.min.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*  www. j a  v a2s  . c om*/
if ($('p').has('#unique')) {
    console.log($('p').html());
    $('p').find('br').remove();
    console.log($('p').html());
}
    });

      </script> 
 </head> 
 <body> 
  <p> <br> <br> <img id="unique" src="http://www.java2s.com/style/demo/Safari.png"> <br> </p>  
 </body>
</html>

Related Tutorials