Remove   from html using regex - Javascript RegExp

Javascript examples for RegExp:Match HTML

Description

Remove   from html using regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from w w w  . j  av a 2  s.  c o  m*/
var el = document.querySelector('.country-IN');
el.innerHTML = el.innerHTML.replace(/&nbsp;/g,'');
    }

      </script> 
   </head> 
   <body> 
      <div class="country-IN"> 
         <span class="locality">locality</span>
          &nbsp;&nbsp; 
         <span class="state">state</span>
          &nbsp;&nbsp; 
         <span class="country">country</span> 
      </div>  
   </body>
</html>

Related Tutorials