www.webdeveloper.com
Results 1 to 2 of 2

Thread: document.write issue

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    document.write issue

    Hi ...the document.write prints out x.innerHTML instead of printing out the paragraph...what is my issue?

    <!DOCTYPE html>
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="idpraccy.css"
    </head>
    <body>
    <p id="myid1">the quick brown fox jumped over the lazy dogs back<p>
    <p id="test">this is a test paragraph<p>
    <script>
    var x=document.getElementById("test");
    document.write("x.innerHTML");
    </script>
    </body>
    </html>

  2. #2
    Join Date
    Mar 2011
    Posts
    1,141
    The quotation marks around "x.innerHTML" mean its a string literal, not a variable. Your code should read:
    Code:
    document.write(x.innerHTML);
    Rick Trethewey
    Rainbo Design

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles