javascript - a href link clicked and div displays image -
i javascript method display image in div depending on href link clicked.
i have written code needs developing further.
<script type=" "> function changeimg(){ var image1 = new image(); image1.src='car.png' var imghol = document.getelementbyid("imageholder"); var elements = document.getelementbyid("fs"); if(elements.onclick = function()){ imghol = image1; } </script> <div class="ads2"><h2>vehicle part</h2><p>please select part wish find; <div class="vertical_menu"> <ul> <li><a id="fs" href="#home" onclick="changeimg">front side</a></li> <li><a id="rs" href="#news">rear side</a></li> <li><a id="s" href="#contact">side</a></li> <li><a id="us"href="#about">under side</a></li> <li><a id="i" href="#about">interior</a></li> </ul> </div> <div class="imageholder"> </div> </div>
keep simple. try this:
<script type="text/javascript"> function changeimg(image){ var imghol = document.getelementbyid("imageholder"); imghol.src = image; } </script> <div class="ads2"> <h2>vehicle part</h2> <p>please select part wish find;</p> <div class="vertical_menu"> <ul> <li><a id="fs" href="javascript:" onclick="changeimg('car.jpg');">front side</a></li> <li><a id="rs" href="javascript:" onclick="changeimg('rear.png')">rear side</a></li> <li><a id="s" href="javascript:" onclick="changeimg('caside.png')">side</a></li> <li><a id="us" href="javascript:" onclick="changeimg('under.png')">under side</a></li> <li><a id="i" href="javascript:" onclick="changeimg('interior.png')">interior</a></li> </ul> </div> <div class="imageholder"><img id="imageholder" /></div> </div>
Comments
Post a Comment