javascript function calling

In the following example, three functions are called against three buttons with type=”button”

<!DOCTYPE html>
<html>
<head>
    <title></title>
  <meta charset="utf-8" />

    <script language="javascript" type="text/javascript">
        function redColor()
        {
            document.bgColor = "red";
        }

        function blueColor()
        {
            document.bgColor = "blue";
        }

        function greenColor()
        {
            document.bgColor = "green";
        }
    </script>
</head>
<body>



<input id="btn1" name="btn1" type="button" value="Red" onclick="redColor();" /><br /><br />
<input id="btn2" name="btn2" type="button" value="Green" onclick="greenColor();" /><br /><br />
<input id="btn3" name="btn3" type="button" value="Blue" onclick="blueColor();"  /><br /><br />
</body>
</html>

 

Add a Comment

Your email address will not be published. Required fields are marked *