jQuery Page Widget How to - Replace the text in side the content








Question

We would like to know how to replace the text in side the content.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!-- w ww  .j  a va 2  s. c om-->
    $('em').each(function(){
          $(this).html($(this).html().replace(/yes/g, ''));
       });
});//]]>  
</script>
</head>
<body>
  <p>
    <em> <a href=''>not</a> yes yes yes
    </em>
  </p>
</body>
</html>

The code above is rendered as follows: