Graeme Hackston
01-06-2003, 07:01 AM
I have 2 questons regarding the example here:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/removechild.asp
This is the code:
<html>
<HEAD>
<SCRIPT>
function removeElement()
{
try
{
//The first child of the div is the bold element.
var oChild=Div1.children(0);
Div1.removeChild(oChild);
}
catch(x)
{
alert("You have already removed the bold element.
Page will be refreshed when you click OK.")
document.location.reload();
}
}
</SCRIPT>
</HEAD>
<BODY>
<DIV ID=Div1 onclick="removeElement()">
Click anywhere in this sentence to remove this <B>Bold</B> word.
</DIV>
</BODY>
</html>
1/ Where does the "x" come from in "catch(x)" ?
2/ When removing the element, how do I make a variable of the division id ?
example:
a = '1'
document.getElementById('Div' + a)
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/removechild.asp
This is the code:
<html>
<HEAD>
<SCRIPT>
function removeElement()
{
try
{
//The first child of the div is the bold element.
var oChild=Div1.children(0);
Div1.removeChild(oChild);
}
catch(x)
{
alert("You have already removed the bold element.
Page will be refreshed when you click OK.")
document.location.reload();
}
}
</SCRIPT>
</HEAD>
<BODY>
<DIV ID=Div1 onclick="removeElement()">
Click anywhere in this sentence to remove this <B>Bold</B> word.
</DIV>
</BODY>
</html>
1/ Where does the "x" come from in "catch(x)" ?
2/ When removing the element, how do I make a variable of the division id ?
example:
a = '1'
document.getElementById('Div' + a)