javascript - Instant image loading using jquery -
well searching on internet way load images instantly using jquery, didn't found anything. use:
<select> <option>image 1</option> <option>image 2</option> <option>image 3</option> </select>
so want load image instantly after clicking on 1 of option. how can it? thank you.
edit after clicking on 1 of option load image, without refreshing page
here simple example:
// when option selected $('#imageselect').on('change',function(){ // change image's src selected value $('#myimage').attr('src', $(this).val()); // once on page load if necessary }).change();
img{display:block;max-width: 50%;} /* demo */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select id="imageselect"> <option value="http://i62.tinypic.com/2088l0l.jpg">image 1</option> <option value="http://i58.tinypic.com/2rfv4b6.jpg">image 2</option> <option value="http://i62.tinypic.com/9a7nk4.jpg">image 3</option> </select> <!-- image holder --> <img src="" id="myimage" alt="" />
Comments
Post a Comment