Tuesday, September 2, 2014

Change background color on Hover and onClick using Javascript

This is an example of how to change the background color using the OnClick and Hover using javascript.



Javascript Function

<script language="JavaScript">
    function changebg(color){
        document.bgColor = color;
    }
</script>

Mouseover Change Bg Color

<p><a href="#" onMouseOver="javascript:changebg('#EB2525')">Mouseover <strong>Red</strong></a></p>

MouseClick Change Bg Color

<p><a href="#" onclick="javascript:changebg('#000099')">MouseClick <strong>Blue</strong></a></p>

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

No comments:

Post a Comment