jquery - Javascript replaceing img file -
i working on website needs use javascript. need javascript use external page. don't quite understand how this. have 5 files on computer needs able replace image file's name , alt. cant use http though.
i have code image:
<img src="images/cablecar.jpg" width="480" height="270" alt="cable car turnaround" id="gallery" />
i need use javascript change cablecare , alt part new image file , description while using onmouseover. code have far javascript:
function switchpix(file, desc){ var line = '<img src= asian.jpg width=\'480\' height=\'270\' alt= +desc+/>'; document.getelementbyid("pix").write(line); }
html:
<figure id="pix" class="right"> <script src="scripts/gallery.js"> </script> <img src="images/cablecar.jpg" width="480" height="270" alt="cable car turnaround" id="gallery" /> </figure> <ul> <li><a href="http://www.asianart.org/" onmouseover="switchpix(asian, asian market)">asian art museum</a></li>
i have use word file replace cablecar asian file name asian.jpg @ end code suppose change image on page image when mouse put on 1 of 5 links.
sorry if bit confusing having trouble understanding myself , wasn't given enough information understand how myself.
hi try use code
<figure id="pix" class="right"> <script src="scripts/gallery.js"> </script> <img src="images/cablecar.jpg" width="480" height="270" alt="cable car turnaround" id="gallery" /> </figure> <ul> <!-- fix onmouseover (all small case) , string parameters --> <li><a href="http://www.asianart.org/" onmouseover="switchpix('asian.jpg', 'asian market')">asian art museum</a></li>
and javascript code work
function switchpix(file, desc) { var $elm = document.getelementbyid("gallery"); $elm.src = file; $elm.alt = desc; }
Comments
Post a Comment