Change color with Javascript : color : Style Basics HTML CSS TUTORIALS


HTML CSS TUTORIALS » Style Basics » color »

 

Change color with Javascript


 

<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Fix Colors</title>
 <script type="text/javascript" language="javascript">
<!--
function swapit(element) {
    var myElement = document.getElementById(element);
    myElement.style.color="red"
}
function revert(element) {
    var myElement = document.getElementById(element);
    myElement.style.color="black"
}
// -->
</script>
</head>
<body>
<h1 id="changeme">Changing Color</h1>
<p  onmouseover="swapit('changeme')" onmouseout="revert('changeme')">
This is a test. This is a test. This is a test. .</p>
</body>
</html>

 



HTML code for linking to this page:

Follow Navioo On Twitter

HTML CSS TUTORIALS

 Navioo Style Basics
» color