Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Beginner DOM

  1. #1
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Beginner DOM

    Hello ,

    I just started learning what DOM is - though it is ssimilar to HTML it hasthat parent uncle...

    And in one of my tests i did something wrong and here it is -

    <html>
    <body>
    <div align="center" id="maindiv">Hello I want fruit for today, OK ?</div>
    <button onclick="asd()">Remove The DIV</button>
    <script>
    var x=document.getElementById("maindiv");
    function asd() {
    x.parentNode.removeChild(x);
    }
    </body>
    </html>

    Please can anyone tell me whats wrong

  2. #2
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    arent you supposed to put a </script> ? or does that not matter

  3. #3
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Lol what a typo

    Thats correct ma lad i forgot to put the script tag (end) in

  4. #4
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    your welcome :P happy to help

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Like I said, if your pages don't validate, there's no guarantee you'll be able to use DOM methods.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Feb 2007
    Location
    Montreal,Quebec
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you shouldn't put your scripts in the body plus try to add the scripts language and type.

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by CrazyCoder View Post
    you shouldn't put your scripts in the body plus try to add the scripts language and type.
    Forget language, its deprecated. Type is all that is required for valid script tags. The language attribute will not validate but, it can be useful for hacks if you want to go down that slippery slope.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Grrrrr, i never liked dumb sorry dom in the first place, document.getElementById was just fine and so was innerHTML...

  9. #9
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Whats not valid about it though APART from the type part - i read that was not required

  10. #10
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Were did every one run off too !!??

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
  •