Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getElementsByTagName bug ?

Status
Not open for further replies.

c3f8

Programmer
Jul 16, 2007
8
PT
Hi there.

Iam facing a very strange problem.

starting with the code:

<html>
<script language = 'javascript'>
function init(){
var x = window.document.getElementById("z");
var temp = x.getElementsByTagName("a");
x.removeChild(temp[1]);
}
</script>
<body onload = "init();">
<div id = "z">
<div>
<a>ola</a>
<a>oli</a>
<a>ole</a>
</div>
</div>
</body>
<html>

The problem here is that i can't remove any <a> in this case because temp[n] isn't a node and it should be.

Thanks
 
Not every line not working is a bug.

>x.removeChild(temp[1]);
[tt]temp[1].parentNode.removeChild(temp[1]);[/tt]
 
thanks a lot.

the problem was that alert(temp[1]) showed a string. i was thinking that temp[1] was not representing a node object when i was removing it.

thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top