Remove an element that doesn't have ID or Name

Discussion in 'JavaScript' started by sajjadlove, Jul 10, 2010.

  1. #1
    Hi all
    we have a page that a div tag added at the first line of its html codes, means before the HTML tag like the following code:
    
    <div style="position:absolute;left:1;top:1;width:122;border:1px solid #C0C0C0;z-index:10;background-color:white"  id="634143432" dir="ltr">
    <table>
    .
    .
    </table>
    <html>
    .
    .
    
    Code (markup):
    the ID attribute is variable and i can't access it with getElementById function....
    whould u please help me about removing this div from my html codes?
     
    sajjadlove, Jul 10, 2010 IP
  2. tdemetri

    tdemetri Peon

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use this and it will work as long as it really is the first div tag on the page ( which means it has an index of 0 in the array of div tags on the page)

    
    	document.getElementsByTagName("div")[0].style.display="none";
    
    Code (markup):
     
    tdemetri, Jul 10, 2010 IP