Replace img link via jquery

This code will find all img tags  in the page that point to the image _layouts/images/gosearch.gif and replace it with another link.

<script src=”http://code.jquery.com/jquery-latest.js”></script>
 <script>
$(document).ready(function() {
$(“img[src*=’_layouts/images/gosearch.gif’]”).attr(‘src’, ‘_layouts/images/newicon.gif’);
$(“img[onmouseover*=’/_layouts/images/gosearch.gif’]”).attr(‘onmouseover’“this.src=’_layouts/images/newicon.gif'”);

$(“img[onmouseout*=’/_layouts/images/gosearch.gif’]”).attr(‘onmouseout’, “this.src=’_layouts/images/newicon.gif'”);
});
Advertisements

Tags:

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: