css - jquery change image src and div positions onselect -


i have select box, want onchange image have change, , other divs change thier (css:top,right values) how jquery?

i have code right (not in jquery , not change top,right of other divs..)

<script type="text/javascript">     function swapimage(){         var image = document.getelementbyid("img");         var dropd = document.getelementbyid("text");         image.src = dropd.value;         }; </script>  <select id="text" onchange="swapimage()" style="width:70px;">     <option value="images/1.jpg">1</option>     <option value="images/2.jpg">2</option>     <option value="images/3.png">3</option> </select> 

here html working (you can inspect image element see src changing): http://jsfiddle.net/69gnc/1/

$("#text").on("change", function() {     $("#img").prop("src", $(this).val());     // add other req.:     // $("#otherdiv").css({"top": "10px", "left": "15px" }); }); 

note: you'll want make sure dom accessible when code reached, reason wrap in $document.ready(function() { [code here] });


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -