Script Output


#1

What is expected as an output to the function below? There is no output on the screen. Will the addition of code like a “print” statement output show the error?

<html>
<head>
  <title>getElementById example</title>
</head>
<body>
  <p id="para">Some text here</p>
  <button onclick="changeColor('blue');">blue</button>
  <button onclick="changeColor('red');">red</button>
</body>
</html>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div id="parent-id">
        <p>hello word1</p>
        <p id="test1">hello word2</p>
        <p>hello word3</p>
        <p>hello word4</p>
    </div>
   <script>
        var parentDOM = document.getElementByID('parent-id');
        var test1=parentDOM.getElementByID('test1');
        throw error
        Uncaught TypeError: parentDOM.getElementById is not a function
   </script>
</body>
</html>

#2

What lesson exactly does this refer to? Is it a lesson? Please post a link to the exercise if so.

There is definitely a problem with the HTML. Sort that out first and try to rephrase your question so we can relate it to the markup.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.