当用户单击单选框时,如何使用 Jquery 显示隐藏的 DIV?
当用户选择单选框时,我很难显示隐藏的 div。
这是我的代码:
Jquery
<script>
$(document).ready(function () {
$(".paypalmethod").click(function() {
$(".paypalinfo").show('slow');
});
</script>
html
<input name="method" type="radio" value="paypal" class="paypalmethod"/><img src="/images/paymentlogos/PayPal.png" />
<div class="paypalinfo" style="display:none">Paypal the safe and easy way to pay. Paypal accepts all major credit cards.</div>
I am having difficulty showing a hidden div when a user selects a radio box.
This is my code:
The Jquery
<script>
$(document).ready(function () {
$(".paypalmethod").click(function() {
$(".paypalinfo").show('slow');
});
</script>
The html
<input name="method" type="radio" value="paypal" class="paypalmethod"/><img src="/images/paymentlogos/PayPal.png" />
<div class="paypalinfo" style="display:none">Paypal the safe and easy way to pay. Paypal accepts all major credit cards.</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在代码中缺少关闭
});
,您需要关闭document.ready
和.click()
,例如另外,为了在元素已经可见时不产生淡入淡出,请添加
:hidden< /code> 选择器
就像我上面的那样。这使得它仅在当前隐藏的元素中查找/淡入,并且在元素已经显示时不会重新淡入。
You're missing a closing
});
in your code, you need to close thedocument.ready
and the.click()
, like this:Also, to not produce a fade when the element's already visible, add a
:hidden
selector in like I have above. This makes it only find/fade in the element if it's currently hidden, and wont re-fade it in when it's already shown.这是一个语法错误。您需要关闭第二个函数和 jQuery 调用:
It's a syntax error. You need to close your second function and jQuery call: