js总报错,我也找不到,求大神帮忙
<!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><title>Document</title><linkr...
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="1.css">
</head>
<body>
<div class="zt">
<div id="nk">
<div class="xk1"><p class="p11">1</p><p class="p1">JAN</p></div>
<div class="xk11"><p class="p11">2</p><p class="p1">FER</p></div>
<div class="xk2"><p class="p11">3</p><p class="p1">MAR</p></div>
<div class="xk1"><p class="p11">4</p><p class="p1">APR</p></div>
<div class="xk11"><p class="p11">5</p><p class="p1">MAY</p></div>
<div class="xk2"><p class="p11">6</p><p class="p1">JUN</p></div>
<div class="xk1"><p class="p11">7</p><p class="p1">JUL</p></div>
<div class="xk11"><p class="p11">8</p><p class="p1">AUG</p></div>
<div class="xk2"><p class="p11">9</p><p class="p1">SEP</p></div>
<div class="xk1"><p class="p11">10</p><p class="p1">OCT</p></div>
<div class="xk11"><p class="p11">11</p><p class="p1">NOV</p></div>
<div class="xk2"><p class="p11">12</p><p class="p1">DEC</p></div>
</div>
<div id="dk">
<div class="jl"><p class="p2">1月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">2月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">3月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">4月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">5月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">6月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">7月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">8月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">9月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">10月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">11月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">12月</p><p class="p2">睡觉</p></div>
</div>
</div>
</body>
<script type="text/javascript">
var nk=document.getElementById('nk');
var div='nk'.getElementsByTagName('div');
for(i=0;i<div.length;i++){
div[i].onmouseover=function(){
for(j=0;j<div.length;j++){
if(div[j]==this){
div[i].className='xka';
}
}
}
}
</script>
</html>
总说我这行错了var div='nk'.getElementsByTagName('div'); 展开
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="1.css">
</head>
<body>
<div class="zt">
<div id="nk">
<div class="xk1"><p class="p11">1</p><p class="p1">JAN</p></div>
<div class="xk11"><p class="p11">2</p><p class="p1">FER</p></div>
<div class="xk2"><p class="p11">3</p><p class="p1">MAR</p></div>
<div class="xk1"><p class="p11">4</p><p class="p1">APR</p></div>
<div class="xk11"><p class="p11">5</p><p class="p1">MAY</p></div>
<div class="xk2"><p class="p11">6</p><p class="p1">JUN</p></div>
<div class="xk1"><p class="p11">7</p><p class="p1">JUL</p></div>
<div class="xk11"><p class="p11">8</p><p class="p1">AUG</p></div>
<div class="xk2"><p class="p11">9</p><p class="p1">SEP</p></div>
<div class="xk1"><p class="p11">10</p><p class="p1">OCT</p></div>
<div class="xk11"><p class="p11">11</p><p class="p1">NOV</p></div>
<div class="xk2"><p class="p11">12</p><p class="p1">DEC</p></div>
</div>
<div id="dk">
<div class="jl"><p class="p2">1月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">2月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">3月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">4月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">5月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">6月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">7月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">8月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">9月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">10月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">11月</p><p class="p2">睡觉</p></div>
<div class="jl"><p class="p2">12月</p><p class="p2">睡觉</p></div>
</div>
</div>
</body>
<script type="text/javascript">
var nk=document.getElementById('nk');
var div='nk'.getElementsByTagName('div');
for(i=0;i<div.length;i++){
div[i].onmouseover=function(){
for(j=0;j<div.length;j++){
if(div[j]==this){
div[i].className='xka';
}
}
}
}
</script>
</html>
总说我这行错了var div='nk'.getElementsByTagName('div'); 展开
2个回答
展开全部
var div='nk'.getElementsByTagName('div'); ‘nk’应该不需要加引号了
改为:var div=nk.getElementsByTagName('div');
改为:var div=nk.getElementsByTagName('div');
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询