日期:2014-05-16  浏览次数:20476 次

下面代码为什么在IE下正常,而在firefox下就没法使用
各位大侠,下面代码为什么在IE下正常,而在firefox下就没法使用
?怎么修改!谢谢!
<html>
<head>
<script type="text/javascript" src="http://www.w3school.com.cn/jquery/jquery.js"></script>
<script type="text/javascript">
function showsubmenu(obj,sid,id){
$(document).ready(function(){
if(obj.checked==true)
$("."+sid).click(function(){
  $("."+id).hide();
  });
else
  $("."+sid).click(function(){
  $("."+id).show();
  });

});
}
</script>
</head>
<body>
<div id="one" class="two">0.</div>
<div id="one" class="two">0</div>
<div id="one" class="two">0.</div>
<div id="one" class="two1">1</div>
<div id="one" class="two1">1</div>
<div id="one" class="two1">1</div>
<input type="checkbox" name="btn1" class="btn1" value="1" onClick='showsubmenu(this,"btn1","two")'>0
<input type="checkbox" name="btn1" class="btn2" value="1" onClick='showsubmenu(this,"btn2","two1")'>1
</body>
</html>


------解决方案--------------------
HTML code

<html>
<head>
<script type="text/javascript" src="http://www.w3school.com.cn/jquery/jquery.js"></script>
<script type="text/javascript">
function showsubmenu(obj,sid,id){
if(obj.checked==true){
  $("."+id).hide();
}

else{
  $("."+id).show();
}

}
</script>
</head>
<body>
<div id="one1" class="two">0.</div>
<div id="one2" class="two">0</div>
<div id="one3" class="two">0.</div>
<div id="one4" class="two1">1</div>
<div id="one5" class="two1">1</div>
<div id="one6" class="two1">1</div>
<input type="checkbox" name="btn1" class="btn1" value="1" onClick='showsubmenu(this,"btn1","two")'>0
<input type="checkbox" name="btn1" class="btn2" value="1" onClick='showsubmenu(this,"btn2","two1")'>1
</body>
</html>