|
How can we get childNodes from a custom tag?
Hello dudes, i wrote a very simple HTML page to test some DOM features between Mozilla and IE. Mozilla is perfect everything went fine and i got the childNodes from my custom tag ( this tag i named <blah> ), inside this tag there is two <span>, that i retrieved. But with IE i really could figure out how its done! Here is my test below, i´d glad if someone point me how it could be done for IE also.
Regards,
LottaLava
<html>
<head>
<script language="JavaScript">
function test( )
{
var obj = document.getElementsByTagName( "blah" );
var span = null;
for ( var i = 0; i < obj.length; i++ )
{
if ( obj[ i ] != null )
{
alert( obj[ i ].getAttribute( "name" ));
for ( var j = 0; j < obj[ i ].childNodes.length; j++ )
{
span = obj[ i ].childNodes[ j ];
if ( span.nodeName == "SPAN" )
alert( span.getAttribute( "name" ));
}
}
}
}
</script>
</head>
<body>
<form name="frmMain"
method="POST"
action="http://localhost/blah">
<span name="span01"><p>1</span><br>
<span name="span02"><p>2</span><br>
<blah name="tblBlah">
<span name="span03"><p>3</span><br>
<button type="button" name="btBlah" onClick="test( );">Test</button>
<span name="span04"><p>4</span><br>
</blah>
</form>
</body>
</html>
|