javascript - Select image by default on page load -
I have a JSON feed and I have the values to populate a selection menu with product size, color / thumbnail Extract and submit the value in an object.
What I want, is to select an image by default, if its title matches the value of a declared variable and has been started at the top (like < Code> var initialColour = "wheat"; ). So if the initial color is "brown", the image titled "brown" should be selected by default and should reflect the size selection in the dropdown menu.
This is what I am trying to:
if (main img.reiter ('title') == initial collar) {$ (this) .addClass (" Active "); }
This is on the 27th line on the jsfiddle link below.
I appreciate any indication of the structure, I know its a mess.
What do you want to do?
I have changed some code in two places, I have left an original reference there. Actually, I have fixed the image directly to mainImg
. Then use that, even when adding the class, besides, you missed some '
s in the image html:
$ ("& lt; img src = "+ BuildImageURL (mainImgID) +" id = "+ MainImgID +" class = 'colorhumb' title = "+ color +" data-value = '"+ color +"' & gt; ")
Comments
Post a Comment