Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Posts
    143
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how can i know if element is not exists in document

    Hello
    im trying to know if some html object is on the document
    but when i try simple :
    alert(document["foo"].id) it even don't alert the alert...
    by the way in this example there is no foo object .
    so.. how can i know if object is NOT exists??
    thanks

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, becuase you have some illegal syntax there. try something like this
    Code:
    function getNode( id )
    {
    	return ( document.all || document.getElementById )( id );
    }
    
    alert( getNode( "foo" ) );
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

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