Search Text and Replace with JavaScript - Javascript jQuery

Javascript examples for jQuery:Text

Description

Search Text and Replace with JavaScript

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.8.3.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from  w  w  w .  j  a v a 2s  . c om*/

var ele = $("div.description");

ele.html(ele.html().replace(/smile/gi,"think"));

    });

      </script> 
   </head> 
   <body> 
      <div class="description">
          I make you smile and cry. 
      </div>  
   </body>
</html>

Related Tutorials