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> 

fiddle


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -