jquery click() 问题,如何解决?
我有这样的设置:
<script type="text/javascript">
$(document).ready(function() {
$("#click_me_link").click(function () {
$("#link_more").show("slow");
});
});
</script>
<div id="click_me_link"><img src="/images/banner_bottom.png"></div>
<div id="link_more" style="width: 530px; height: 66px; display: none;">
test
</div>
如果我点击 click_me_link
它不会显示隐藏的 div。如果我在控制台中运行 $("#link_more").show("slow");
它有
什么想法吗? 谢谢 分号已修复,仍然不起作用
i have this setup:
<script type="text/javascript">
$(document).ready(function() {
$("#click_me_link").click(function () {
$("#link_more").show("slow");
});
});
</script>
<div id="click_me_link"><img src="/images/banner_bottom.png"></div>
<div id="link_more" style="width: 530px; height: 66px; display: none;">
test
</div>
if i click on the click_me_link
it wont display the hidden div. if i run $("#link_more").show("slow");
in the console it works
any idea?
thanks
semicolon fixed, still doesn't work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,问题是你的 link_more 中的 css。您缺少一个分号。它必须是这样的:
无论如何,您可能希望将 click_me_link 设置为锚点而不是 div,并在单击事件中使用 e.preventDefault() 。
Yeah the issue is your css in link_more. You are missing a semicolon. It needs to be this:
Anyway, you probably want to make click_me_link an anchor instead of a div and use e.preventDefault() inside your click event.
它在这里工作 http://jsfiddle.net/imoda/eXPW5/
您缺少
;
在 height 属性之后不确定这是否会导致您的问题,因为我似乎无法复制它,但毫无疑问需要修复。
It's working here http://jsfiddle.net/imoda/eXPW5/
You're missing a
;
after the height propertyNot sure if that's causing your problem as I can't seem to replicate it, but it's no doubt something to fix.
您在“66px”后面缺少一个分号。除此之外,你的例子对我有用。
这是一个工作的 jsfiddle:
http://jsfiddle.net/Mm9AQ/
You were missing a semi-colon after "66px". Other than that, your example is working for me.
Here is a working jsfiddle:
http://jsfiddle.net/Mm9AQ/