<<html xmlns="http://www.w3.org/1999/xhtml">>
<<head>>
<<title>>Delete and Replace Demo<</title>>
<<meta http-equiv="content-type" content="text/html" charset="ISO-8859-1" />>
<<script language="text/javascript">>function conductDelete()
{
var deletePoint = document.getElementById('toDelete');
if (deletePoint.hasChildNodes())
deletePoint.removeChild(deletePoint.lastChild);
}
function conductReplace()
{
var replace = document.getElementById('toReplace');
if (replace)
{
var newNode = document.createElement("strong");
var newText = document.createTextNode("strong element");
newNode.appendChild(newText);
replace.parentNode.replaceChild(newNode, replace);
}
}
<</script>>
<</head>>
<<body>>
<<div id="toDelete">>
<<p>>This is a paragraph<</p>>
<<p>>This is <<em>>another paragraph<</em>> to delete<</p>>
<<p>>This is yet another paragraph<</p>>
<</div>>
<<p>>
This paragraph has an <<em id="toReplace">>em element<</em>> in it.
<</p>>
<<hr />>
<<form action="#" method="get">>
<<input type="button" value="Click me" onclick="conductDelete()">>
<<input type="button" value="Replace" onClick= "conductReplace()" />>
<</form>>
<</body>>
<</html>>
<<head>>
<<title>>Delete and Replace Demo<</title>>
<<meta http-equiv="content-type" content="text/html" charset="ISO-8859-1" />>
<<script language="text/javascript">>function conductDelete()
{
var deletePoint = document.getElementById('toDelete');
if (deletePoint.hasChildNodes())
deletePoint.removeChild(deletePoint.lastChild);
}
function conductReplace()
{
var replace = document.getElementById('toReplace');
if (replace)
{
var newNode = document.createElement("strong");
var newText = document.createTextNode("strong element");
newNode.appendChild(newText);
replace.parentNode.replaceChild(newNode, replace);
}
}
<</script>>
<</head>>
<<body>>
<<div id="toDelete">>
<<p>>This is a paragraph<</p>>
<<p>>This is <<em>>another paragraph<</em>> to delete<</p>>
<<p>>This is yet another paragraph<</p>>
<</div>>
<<p>>
This paragraph has an <<em id="toReplace">>em element<</em>> in it.
<</p>>
<<hr />>
<<form action="#" method="get">>
<<input type="button" value="Click me" onclick="conductDelete()">>
<<input type="button" value="Replace" onClick= "conductReplace()" />>
<</form>>
<</body>>
<</html>>
改成
<script >