Remove word from substring - Javascript jQuery

Javascript examples for jQuery:String

Description

Remove word from substring

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 ava 2 s  . com
$('a:contains("(foo)")').text(function(_, currentText){
   return currentText.replace('(foo)', '');
})
    });

      </script> 
 </head> 
 <body> 
  <a href="#">test Item 1</a> 
  <a href="#">test Item 2 (foo)</a> 
  <a href="#">test Item 3</a>  
 </body>
</html>

Related Tutorials