jQuery中show()和hide()的问题,
<html><head><style>#repice{display:none;}</style><scriptsrc="js/jquery.js"></script><...
<html>
<head>
<style>
#repice {display:none;}
</style>
<script src="js/jquery.js"></script>
<script>
$(document).ready(function(){
$('.repice-name').bind('click',function(){
$('#repice').show();
///////////////////////////////////////////////////////////////
$('.hide').bind('click',function(){
$('#repice').hide();
});
});
</script>
</head>
<body>
<a href="#" class="repice-name">Key Lime Pie</a>
<div id="repice">
<p>Key Lime Pie is an American dessert made of key lime juice,egg yolks, and sweetended condensed milk in a pie crust.</p>
<a href="#" class="hide">Hide</a>
</div>
</body>
</html>
一个show,一个hide,注释掉hide,show正常,注释掉show,hide正常,但两个在一起就不行了,囧 展开
<head>
<style>
#repice {display:none;}
</style>
<script src="js/jquery.js"></script>
<script>
$(document).ready(function(){
$('.repice-name').bind('click',function(){
$('#repice').show();
///////////////////////////////////////////////////////////////
$('.hide').bind('click',function(){
$('#repice').hide();
});
});
</script>
</head>
<body>
<a href="#" class="repice-name">Key Lime Pie</a>
<div id="repice">
<p>Key Lime Pie is an American dessert made of key lime juice,egg yolks, and sweetended condensed milk in a pie crust.</p>
<a href="#" class="hide">Hide</a>
</div>
</body>
</html>
一个show,一个hide,注释掉hide,show正常,注释掉show,hide正常,但两个在一起就不行了,囧 展开
1个回答
展开全部
拷贝你的代码,测试有错,$(document).read(...);方法里,你的show 和 hide定义的两个方法有一个没闭合,直接运行不了。然后修改已后,再运行就没错了,没有出现你说的“两个一起就不执行了”的情况。 :
<html>
<head>
<style>
#repice {display:none;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('.repice-name').bind('click',function(){
$('#repice').show();
});
$('.hide').bind('click',function(){
$('#repice').hide();
});
});
</script>
</head>
<body>
<a href="#" class="repice-name">Key Lime Pie</a>
<div id="repice">
<p>Key Lime Pie is an American dessert made of key lime juice,egg yolks, and sweetended condensed milk in a pie crust.</p>
<a href="#" class="hide">Hide</a>
</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询