jQuery: Collect img tags based on src then replace them


/ Published in: JavaScript
Save to your folder(s)

This two liner is powerful. It shows you how to find images on a page based on the source (src) and replace them with another image.


Copy this code and paste it in your HTML
  1. var img = $(".columnLeft").find("img[src='/path/to/existing/image/file.png']");
  2. $(img).attr("src", "/path/to/new/image/file.png" );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.