我试图在用户点击“我同意......”文字的Next-Button
后显示checkbox
。
我尝试了()toggle
和show/hide
,但无法使其正常运行。知道如何解决这个问题吗?
的jQuery
<script>
$(document).ready(function(){
$("#i_agree_check").click(function(){
$("next_2_btn_info").hide();
});
$("#i_agree_check").click(function(){
$("next_2_btn_info").show();
});
});
</script>
HTML
<div class="checkbox_agree show"><input type="checkbox" id="i_agree_check"</><?php echo $lang ['i_agree']; ?></div>
<div class="edit_btn"> <!-- Not active placeholder -->
<a href="#" title="<?php echo $lang ['complete_step']; ?>"><?php echo $lang ['next']; ?></a>
</div>
<div class="next_2_btn_info" id="next_2_btn_info">
<a href="order_banner_2.php"><?php echo $lang ['next']; ?></a>
</div>
答案 0 :(得分:1)
$("next_2_btn_info").hide(); //Change
$("#next_2_btn_info").hide();
答案 1 :(得分:1)
试试这个(更新):
$("#next_2_btn_info").hide();
$("#i_agree_check").click(function(){
$("#next_2_btn_info").toggle();
});
答案 2 :(得分:0)
你可以尝试这个吗,你需要在选择器元素之前添加#
或.
,如$("#next_2_btn_info")
$(function(){
$("#i_agree_check").click(function(){
$("#next_2_btn_info").toggle();
});
});
答案 3 :(得分:0)
您正在使用复选框注册两个相互矛盾的click
事件,并且您不使用该按钮的ID。试试这个:
$(document).ready(function(){
$("#i_agree_check").click(function(){
$("#next_2_btn_info").toggle();
});
});
请注意它是#next_2_btn_info
而不是next_2_btn_info
。此外,.toggle()
根据对象的当前状态显示/隐藏。
答案 4 :(得分:0)
您正在$(“#i_agree_check”)上连续两次设置点击处理程序。尝试设置单击处理程序并测试复选框的值以确定它是否已被选中。
$('#i_agree_check').click(function(){
if($("#i_agree_check").is(':checked')) {
$('next_2_btn_info').show();
} else {
$('next_2_btn_info').hide();
}
}