如果我想檢查一個複選框,那麼如果點擊引導模式上的「YES」按鈕,則複選框必須檢查並且如果單擊「否」按鈕則保持取消勾選。如果點擊引導模式上的是按鈕,只勾選複選框
另一方面,如果想取消選中複選框,那麼如果在引導模式中單擊了「YES」按鈕,則複選框必須取消選中並保持檢查是否單擊「否」按鈕。
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<label class="checkbox-inline">
<input type="checkbox" value="" class="status">John Doe
</label>
<label class="checkbox-inline">
<input type="checkbox" value="" class="status" checked>James Doe
</label>
<!-- Activate -->
<div class="modal fade" id="activate" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Activate?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default btn-yes" data-dismiss="modal">Yes</button>
<button type="button" class="btn btn-default btn-no" data-dismiss="modal">No</button> </div>
</div>
</div>
</div>
<!-- Deactivate -->
<div class="modal fade" id="deactivate" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Deactivate?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default btn-yes" data-dismiss="modal">Yes</button>
<button type="button" class="btn btn-default btn-no" data-dismiss="modal">No</button> </div>
</div>
</div>
</div>
</div>
JQUERY
$('.status').click(function(){
if($(this).is(':checked')) {
$('#activate').modal('show');
} else {
$('#deactivate').modal('show');
}
});
的jsfiddle
https://jsfiddle.net/br86rjby/
說這句話 http://jsfiddle.net/dfKEZ/
但只有它應該是一個引導模式
感謝您的幫助!
YES!感謝這:)) – JSmith