Here you can find a number of examples on Java Script.Please find the various kinds of examples listed on the right side of this site. If you don't find anything on Java Script then please write to us or leave a commnet. We are pleased to help and find the solution of your problem.

Javascript: Chage Background and Foreground Color onclick button



<html>
<head>

<script language="javascript">
function changebg(thecolor)
{
document.bgColor=thecolor.value;
}

function changefg(thecolor)
{
document.fgColor=thecolor.value;
}
</script>

</head>
<body>

<b>Background</b>

<form>
<input type=button value="red" onclick="changebg(this)">
<input type=button value="black" onclick="changebg(this)">
<input type=button value="lightyellow" onclick="changebg(this)">
<input type=button value="lightgrey" onclick="changebg(this)">

<p>
<b>Foreground</b>

<b<Welcome to my site</b><p>
<input type=button value="white" onclick="changefg(this)">
<input type=button value="blue" onclick="changefg(this)">
<input type=button value="brown" onclick="changefg(this)">
<input type=button value="darkblue" onclick="changefg(this)">
</form>

</body>
</html>

No comments:

Post a Comment

Google