Remove all special characters in <p> tags using JavaScript/jQuery on page load - Javascript String Operation

Javascript examples for String Operation:String Remove

Description

Remove all special characters in <p> tags using JavaScript/jQuery on page load

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.7.1.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*www. j a  va2s .  c om*/

var string = "this is a'asdf^&&*())) a ssss^ 123123!(^&*&%$^$&%*1 Str!ng@.";
$('body').html(string.replace(/[^a-z0-9\s]/gi, ''));

    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials