html - Changing a an image src file using javascript wont change picture displayed -


essentially have div

<div id="trafficcam" style="text-align:center;display:none;"> <img id="image" src="http://131940.qld.gov.au/dmr.controls/webcams/displayimage.ashx?filepath=gold_coast/grandissth.jpg" alt="sorry, no traffic cam available"> 

and i'd change src of file when button pressed image changes. can't hide , have show different 1 because div traffic cams, , i'd rather have bit more compact.

the button execute is

<input type=button  value="cam" onclick="selectcam()"> 

which have tested , works

the function calls is:

      function selectcam() { alert(document.getelementbyid("image"))              document.getelementbyid("image").src="http://i.imgur.com/zp9ktfe.jpg";           } 

which seems not change on page when button pressed

there no method getelementbyid, it's called getelementbyid. check out error console, there should

unhandled error: 'document.getelementbyid' not function 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -