SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: DHTML Test

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question DHTML Test

    I was wondering why this doesn't work.


    <!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">
    <html>
    <head>
    <title>Test</title>
    <script type="text/javascript">
    function tester() {
    var temp = document.getElementById('myp');
    temp.nodeValue = "success";
    }
    </script>
    </head>
    <body>
    <p id="myp">fail</p>
    <input type="submit" name="Submit" value="Submit" onclick="tester(); return false;" />
    </body>
    </html>

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    temp.firstChild.data = "success";
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    May 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your a genius! thank you!

    Sitepoints DHTML Utopia book claimed i had to use nodeValue.... I'm very disappointed in the book now.

  4. #4
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gravija View Post
    Your a genius! thank you!

    Sitepoints DHTML Utopia book claimed i had to use nodeValue.... I'm very disappointed in the book now.
    Don't be. I own a copy of that book too, and it explains clearly how the text inside HTML tags is also a node. Hence the firstChild.


Bookmarks

Posting Permissions

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