I'm trying to replace the src of an image and I currently have this:
if(('product-img img').src = "/webimages/blank.gif") {
$(".product-img img").attr("src","/images/blank.gif");
}
It is working but it's happening to all the images on the page. I only want it to happen if the image src = /webimages/blank.gif. I've also tried $(this).attr("src","/images/blank.gif");
anyone know what I'm missing? Thanks
You are missging =
, change =
to ==
, the code should as follow:
if($('.product-img img').src == "/webimages/blank.gif") {
$(".product-img img").attr("src","/images/blank.gif");
}
How would i write a function that takes one argument that is a sentence and returns a new sentence where all words are reversed but kept in the same order as the original sentence? Test Case: ...
How would i write a function that takes one argument that is a sentence and returns a new sentence where all words are reversed but kept in the same order as the original sentence? Test Case: ...
im having issues trying to fill a single 10 row textarea with data using ng-repeat instead it creates a new textarea for every data entry. how can i just insert into one? and i would like to make the ...
im having issues trying to fill a single 10 row textarea with data using ng-repeat instead it creates a new textarea for every data entry. how can i just insert into one? and i would like to make the ...
I have the following HEAD tag <head> <title>Test</title> <link id="css1" href="demo.css" rel="stylesheet" type="text/css"> </head> What I want to be able to in ...
I have the following HEAD tag <head> <title>Test</title> <link id="css1" href="demo.css" rel="stylesheet" type="text/css"> </head> What I want to be able to in ...
I'm learning how to use React JS with my Rails app. Disclaimer: This is the first time I am messing around with JS! I'm following a talk by Michael Chan at Rails Conf. Everything works beautifully ...
I'm learning how to use React JS with my Rails app. Disclaimer: This is the first time I am messing around with JS! I'm following a talk by Michael Chan at Rails Conf. Everything works beautifully ...