R.DM
R.DM

Reputation: 105

Inserting into a HTML div tag from a javascript function

I have searched online for a solution to my problem, but I can't seem to fix it. I've tried also using a validator, but still nothing gives. Sorry if you think that this is a repeated question. I just can't seem to find anything. Here's what I did:

    <!DOCTYPE html>

    <html>
 <head>
 <title></title>
 </head>
 <body>

 <p><strong>User Information:</strong></p>

 <button onclick="getUserInfo()">Begin</button>

 <div id=”content”>Hello</div>

 <script type="text/javascript">

 function getUserInfo(){

 var name = prompt("What is your full name?", "Name");
 var age = prompt("How old are you?", "Age");
     if (name !== null && age !== null) {
    document.getElementById("content").innerHTML =
    "Hello, my name is " + name + " and I'm " + age + " years old.";

}           
 }
 </script>


 </body>
 </html>

Upvotes: 1

Views: 34

Answers (1)

chris97ong
chris97ong

Reputation: 7060

Change

<div id=”content”>Hello</div>

to

<div id="content">Hello</div>

It might be the issue here.

Upvotes: 2

Related Questions