Reputation: 434
Here is my html code:
<a href="http://www.google.com/" target="_blank">Google</a>
I need a jquery code to find Google.com and change it to Yahoo.com.
For example, if you click on the Google text then yahoo.com will open in your browser.
Is it possible to use jquery to find all Google texts in current page and replace them with Yahoo?
Upvotes: 1
Views: 233
Reputation:
Code Example:
$('a[href*="google.com"]').each( function (i) {
$(this).attr("href","http://yahoo.com");
});
Fiddle: http://jsfiddle.net/f4WmR/
Useful links
Upvotes: 0
Reputation: 875
This should do the trick:
$('a[href*="google"]').each(function() {
$(this).attr('href', $(this).attr('href').replace(/google/i, 'yahoo');
});
Aside from that I see no reason sinister enough to actually use this...
Upvotes: 2
Reputation: 4540
This is a strange question:
$('a[href*="google"]').each( function (i) {
$(this).attr("src","http://yahoo.com")
});
Upvotes: 0