I want to get the src of one image and set it as another's src when #btn is pressed:
jQuery("#btn").live("click", function() { jQuery("#another_div") .children("img") .attr("src", jQuery(this).prev("img").attr("src")); jQuery(this) .prev("img") .attr("src",""); }) I have also tried:
jQuery(this).prev('img').removeAttr("src"); It works fine in Firefox, IE7-9, and Safari.
Only in Chrome, the image is not removed even when the source changes (src="").
You could change it to
jQuery(this).attr("src", "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="); maybe?
Since in my case by doing this
$(this).attr("src",""); clearing the src attribute, but, image does not vanish. Hence I just set, img tag style attribute display to none, like this
$(this).attr("src","").css("display", "none"); It will hide the image. I hope, it will temporarily work for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With