老大细心点,^=^<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>title...... </title> </head> <script language="javascript"> function modifyx(){ var newElem=document.createElement("p"); newElem.id="newp"; var newText=document.createTextNode("This is the second paragraph."); newElem.appendChild(newText); document.body.appendChild(newElem); document.getElementById("emphasis1").childNodes[0].nodeValue="first"; } </script> <body> <button onClick="modifyx()">add/replace text </button> <p id="paragraph1">this is the <em id="emphasis1">one and only </em> paragraph on the page </p>
<head runat="server">
<title>title...... </title>
</head>
<script language="javascript">
function modifyx(){
var newElem=document.createElement("p");
newElem.id="newp";
var newText=document.createTextNode("This is the second paragraph.");
newElem.appendChild(newText);
document.body.appendChild(newElem);
document.getElementById("emphasis1").childNodes[0].nodeValue="first";
}
</script>
<body>
<button onClick="modifyx()">add/replace text </button>
<p id="paragraph1">this is the <em id="emphasis1">one and only </em> paragraph on the page </p>
</body>
</html>