<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="description" content=""><meta name="keywords" content=""><title>Examples</title><style type="text/css"> *{margin: 0;padding: 0;} a{text-decoration: none;color: #333;} ul,li{list-style: none;} body{font-size: 14px;font-family: "微软雅黑";}</style></head><body><div id="box"> 112444 <span>22</span></div> <script type="text/javascript"> var box = document.getElementById("box"); fn(box.nextSibling.nodeName);//nextSibling返回此对象往后的紧跟节点,以对象方式返回;nodeName返回节点名称 var copy=document.getElementById("box").lastChild.cloneNode("aaa"); document.getElementsByTagName("span").appendChild(copy); function fn(value){ return document.write(value+'\n'); } </script></body></html>实在找不到这26行哪里错了
1 回答
已采纳
西兰花伟大炮
TA贡献376条经验 获得超318个赞
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<title>Examples</title>
<style type="text/css">
*{margin: 0;padding: 0;}
a{text-decoration: none;color: #333;}
ul,li{list-style: none;}
body{font-size: 14px;font-family: "微软雅黑";}
</style>
</head>
<body>
<div id="box">
112444
<span>22</span>
</div>
<script type="text/javascript">
var box = document.getElementById("box");
fn(box.nextSibling.nodeName);//nextSibling返回此对象往后的紧跟节点,以对象方式返回;nodeName返回节点名称
var copy=document.getElementById("box").lastChild.cloneNode("aaa");
document.getElementsByTagName("span")[0].appendChild(copy);
function fn(value){
return document.write(value+'\n');
}
</script>
</body>
</html>因为返回的html集合,要用索引取,26行加上索引,就没错了,但是不知道你代码想干嘛
添加回答
举报
0/150
提交
取消
