如何做到这一点:当我单击一个复选框,但我再次单击它以删除选中的$(".continuar").removeClass("ver");?
我的意思是,当我单击一个复选框时,就会出现下一个按钮,如果我单击第二个复选框,它会更改为复选框,但我希望这样做:当我再次单击第一个或第二个复选框以取消选中时,我希望按钮消失。
这正是我想要的:复选框1未选中= $(".continuar").addClass("ver");复选框2上相同,未选中= $(".continuar").addClass("ver");
我说的是这个按钮
<div class='continuar'>
<input type="button" onclick="siguiente()" value="Continuar" class="boton" />
</div>
<input class="opc1" type="checkbox" value="1" onClick="Califica(1)" />
<input class="opc2" type="checkbox" value="2" onClick="Califica(2)" />function Califica(opc) {
$(".continuar").addClass("ver");
respuestas[pMin]=opc;
if (opc==1) {
$("#p"+pMin+" .respuesta .opciones .opc1").attr('checked', true);
$("#p"+pMin+" .respuesta .opciones .opc2").attr('checked', false);
} else if (opc==2) {
$("#p"+pMin+" .respuesta .opciones .opc1").attr('checked', false);
$("#p"+pMin+" .respuesta .opciones .opc2").attr('checked', true );
} else if(opc == 1 || opc == 2) {
$("#p"+pMin+" .respuesta .opciones .opc1").removeAttr('checked');
$("#p"+pMin+" .respuesta .opciones .opc2").removeAttr('checked');
}
}我试着用Netzach的评论来做这件事,但没有用
函数Califica(opc){
$(".continuar").addClass("ver");
respuestas[pMin]=opc;
if (opc==1){
$("#p"+pMin+" .respuesta .opciones .opc1").attr('checked', true);
$("#p"+pMin+" .respuesta .opciones .opc2").attr('checked', false);
$('.opc1').on("click",function(){
if($(this).attr('checked')) {
$('.button').show();
}else{
$('.button').hide();
}
});
}else if (opc==2){
$("#p"+pMin+" .respuesta .opciones .opc1").attr('checked', false);
$("#p"+pMin+" .respuesta .opciones .opc2").attr('checked', true );
$('.opc2').on("click",function(){
if($(this).attr('checked')) {
$('#button').hide();
}
});
}
}发布于 2015-11-23 16:50:46
如果您单击一个输入,您需要知道是否被选中。您的按钮init $(‘#按钮’).hide();或显示:none。
<div id="button" style="display:none;">YOUR BUTTON</div>
<input class="opc1" type="checkbox" value="1" />
<input class="opc2" type="checkbox" value="2" />
$('.opc1').on("click",function(){
if($(this).prop('checked')) {
$('#button').show();
}else{
$('#button').show();
}
});
$('.opc2').on("click",function(){
if($(this).prop('checked')) {
$('#button').hide();
//Also you can use $('#button').remove(); but if you need show this before don't remove.
}
});发布于 2015-11-23 16:39:26
我不知道你是什么意思,但如果我明白你的意思,你就去找这样的东西:
button{
display:none;
}
input:checked + input:checked + button{
display:block !important;
}Please accept the terms of Conditions<input type="checkbox">
and the License Agreement<input type="checkbox">, thanks!
<button>Thanks, proceed »</button>
https://stackoverflow.com/questions/33875348
复制相似问题