<ul id="test">
<li>JavaScript</li>
<li>HTML</li>
</ul>
<script type="text/javascript">
var otest = document.getElementById("test");
var newNode=document.createElement("li");
newNode.innerHTML="PHP";
otest.appendChild(newNode);
</script>
------------------------------------------------------
<div>
<b id="oldnode">JavaScript</b>是一个很常用的技术,为网页添加动态效果。
</div>
<a href="javascript:replaceMessage()"> 将加粗改为斜体</a>
<script type="text/javascript">
function replaceMessage(){
var newNode=document.createElement("i");
var newNodeText=document.createTextNode("JavaScript");
newNode.appendChild(newNodeText);
var oldNode=document.getElementById("oldnode");
oldNode.parentNode.replaceChild(newNode,oldNode);
}
</script>
MarlboroKay
woshiajuana
乱也
相关分类