按下复选框打开引导模式



我搜索以打开带有复选框的模式#LoginModalStart,但页面会打开带有每个复选框的该模式。

你能帮我吗?

$('input[type="checkbox"]').on('change', function(e) {
if (e.target.checked) {
$("#LoginModalScreenplay").modal();
}
});

$('input[type="checkbox"]')针对页面上的每个复选框。您可能想要针对特定的复选框。像这样的

<input type="checkbox" id="my-special-checkbox">
$('#my-special-checkbox').on('change', function(e) {
if (e.target.checked) {
$("#LoginModalScreenplay").modal();
}
});

您必须将show传递给modal方法:

$('#LoginModalScreenplay').modal('show')

你使用这个,

<input name="checkbox" type="checkbox" id="my-special-checkbox" value=1>
<input name="checkbox" type="checkbox" id="my-special-checkbox" value=2>
<input  name="checkbox" type="checkbox" id="my-special-checkbox" value=3>
<script>
$(document).ready(function(){
$('input[name="checkbox"]').on('change', function(e) {
var x = $(this).val();
$("input:checkbox").prop('checked', false);
if(x==1){
$("input[value="+x+"]").prop('checked', true);
$("#LoginModalScreenplay").modal(); //or $("#LoginModalScreenplay").show();
}
});
});
</script>

最新更新