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

Thursday, 19 June 2014

Event Listeners (addEventListener) in javascript

--------------------------------------------------
<img id="imgk" src="images/smile.jpg" width="100" height="100" border="0" />

<script>
    function smile(){
            document.getElementById('imgk').src = "images/smile.jpg";
        }
    function nosmile(){
            document.getElementById('imgk').src = "images/smile1.jpg";
        }
       
        imgk.addEventListener('mouseover',nosmile);
         imgk.addEventListener('mouseout',smile);
</script>


--------------------------------------------------

No comments:

Post a Comment