-2

All I'm getting in my output is changeColor is not defined and changeAgain is not defined. I have tried to fix it but it doesn't seem to work. Any help would be appreciated, I have looked everywhere!!!

Here's my code

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>

<body onLoad="alert('Website Loaded');">

  <script language="javascript" type="text/javascript">
    function changeColor() {
      document.GetElementById("h3style").style.color = "red";
      document.GetElementById("h3style").firstChild.nodeValue = "RED!";
      return true;
    }

    function changeAgain() {
      document.GetElementById("h3style").style.color = "gray";
      document.GetElementById("h3style").firstChild.nodeValue = "Gray...";
      return true;
    }
  </script>
  <noscript>
    <h1>THIS CONTENT REQUIRES JAVASCRIPT | PLEASE ENABLE JAVASCRIPT</h1>
  </noscript>


  <h3 id="h3style" onMouseOver="changeColor()" onMouseOut="changeAgain()">Scroll on me</h3>

</body>

</html>

1 Answers1

1

It should be getElementById.

Check docs here

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>

<body onLoad="alert('Website Loaded');">

  <script language="javascript" type="text/javascript">
    function changeColor() {
      document.getElementById("h3style").style.color = "red";
      document.getElementById("h3style").firstChild.nodeValue = "RED!";
      return true;
    }

    function changeAgain() {
      document.getElementById("h3style").style.color = "gray";
      document.getElementById("h3style").firstChild.nodeValue = "Gray...";
      return true;
    }
  </script>
  <noscript>
    <h1>THIS CONTENT REQUIRES JAVASCRIPT | PLEASE ENABLE JAVASCRIPT</h1>
  </noscript>


  <h3 id="h3style" onMouseOver="changeColor()" onMouseOut="changeAgain()">Scroll on me</h3>

</body>

</html>
Dhiraj
  • 33,140
  • 10
  • 61
  • 78
  • Thankyou. I know its a simple thing but im just starting javascript! – notBillGates Mar 08 '15 at 19:04
  • you're welcome. I'm glad it helped. https://developer.mozilla.org/en-US/ is a good resource. Also please mark it as answered if that is the solution you're looking for. – Dhiraj Mar 08 '15 at 19:22