Learn free online HTML5, javascript, and jquery Tutorials by Examples

Thursday, 31 March 2016

onselect image change in jquery

<img src="" name="image-swap">
        <select name="img-change" id="img-change">
            <option value="imag1.jpg">Red</option>
            <option value="imag2.jpg">Black</option>
            <option value="imag3.jpg">White</option>
        </select>

<script>
     $(document).ready(function(){
           $("#img-change").change(function(){
                $("img[name=image-swap]").attr("src",$(this).val());
            });
     });
</script>

No comments:

Post a Comment