html - Javascript img tag src switch function not working -
i have small app uses 3 images buttons, images different colors, above image buttons there big pair of glasses, depending on color button press color of glasses change match color of button pressed. problem getting "cannot set src null" error.
here jsfiddle: http://jsfiddle.net/vaf8s/
here function
//functions change glasses image function changecolor(a){ var img = document.getelementbyid("imgg"); img.src=a; }
you have 2 id's tag. should have 1 id. change html.
<section id="banner" > <img id="imgg" src="images/orangeg.png"><br> <img id="wcolorbutton" src="images/whitet.png" /> <img id="bcolorbutton" src="images/bluet.png" /> <img id="ocolorbutton" src="images/oranget.png" onclick="changecolor('images/whiteg.png')" /> </section>
Comments
Post a Comment