function clearText() {
var content=document.getElementById("content");
// 在此完成該函數
if(content.lastChild.nodeType != 1){
content.removeChild(content.lastChild);
}
var del=content.removeChild(content.lastChild);
alert("移除的節點是:"+del.innerHTML);
}
var content=document.getElementById("content");
// 在此完成該函數
if(content.lastChild.nodeType != 1){
content.removeChild(content.lastChild);
}
var del=content.removeChild(content.lastChild);
alert("移除的節點是:"+del.innerHTML);
}
2019-10-13
document.write(arr[0]+'<br/>'+arr[arr.length-1]+'<br/>'+arr[2]+'<br/>'+arr[4]+'<br/>')
var myarr = new Array(3); //先聲明一維
for(var i=0;i<myarr.length;i++){ //一維長度為2
myarr[i]=new Array(6); //再聲明二維
for(var j=0;j<myarr[i].length;j++){ //二維長度為3
myarr[i][j]=i*j; // 賦值,每個數組元素的值為i+j
}
}
for(var i=0;i<myarr.length;i++){ //一維長度為2
myarr[i]=new Array(6); //再聲明二維
for(var j=0;j<myarr[i].length;j++){ //二維長度為3
myarr[i][j]=i*j; // 賦值,每個數組元素的值為i+j
}
}
function createa(url,text)
{
var body=document.body;
var h=document.createElement("a");
h.setAttribute("href",url);
h.setAttribute("color","red");
h.setAttribute("target","_blank");
h.innerHTML=text;
body.appendChild(h);
}
createa("http://www.xianlaiwan.cn","慕課網");
不加target不行
{
var body=document.body;
var h=document.createElement("a");
h.setAttribute("href",url);
h.setAttribute("color","red");
h.setAttribute("target","_blank");
h.innerHTML=text;
body.appendChild(h);
}
createa("http://www.xianlaiwan.cn","慕課網");
不加target不行
2019-09-27
document.write(mylist.parentNode.parentNode.parentNode.childNodes[7].childNodes[1].childNodes[i].firstChild.nodeValue+'<br>');
空格編號是0/(1)li/2/(3)li/4/(5)li/6/(7)li , 最后沒有8. 就是一共2N個,編號從0-----2N-1
空格編號是0/(1)li/2/(3)li/4/(5)li/6/(7)li , 最后沒有8. 就是一共2N個,編號從0-----2N-1
2019-09-27
<script type="text/javascript">
var x=document.getElementById("con");
document.write(x.childNodes[1].firstChild.nodeValue+'<br>');
document.write(x.childNodes[x.childNodes.length - 2].firstChild.nodeValue);
</script>
var x=document.getElementById("con");
document.write(x.childNodes[1].firstChild.nodeValue+'<br>');
document.write(x.childNodes[x.childNodes.length - 2].firstChild.nodeValue);
</script>
2019-09-27