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

Wednesday 21 May 2014

JavaScript Can Change HTML Attributes

-------------------------------------------
<img id="my_Image" onclick="change_Image()" src="path of the image" width="100" height="180">

<script>
function change_Image() {
    var image = document.getElementById('my_Image');
    if (image.src.match("bulbon")) {
        image.src = "path of the image";
    } else {
        image.src = "path of the image";//another Image
    }
}
</script>
------------------------------------------

No comments:

Post a Comment