my code does not work I don’t know why?? I have WordPress.
A WordPress plugin injects some code from an external site into my wordpress site.
The code loads up from the external website and displays some images, which are ugly, on my wordpress site. So I wanna replace the ugly images with my own images. I cannot edit the HTML code from the external site.
Here is my code which I inserted into the footer.php.
<script type="text/javascript">
jQuery(document).ready(function() {
var the_image_source = "http://original.xyz/original.png";
var new_src = "/wp-content/images/myone.png";
jQuery('img[src=' + the_image_source + ']').attr('src',new_src);
});
</script>
I don’t know what’s wrong, so please help me! Thank you!
If you add double quotes inside the selector it will work:
Demo here