作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含 3 个复选框的引导模式。检查2个。我想做这样的事情当用户打开模式并对复选框进行更改时。如果他关闭模式,我希望复选框返回到模式打开时的状态。有没有办法可以在 jquery 中完成
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><i class="icon-bar-chart"> </i> Modules</h3>
</div>
<div class="modal-body">
<label class="checkbox ">
<input type="checkbox" value="option1" checked> 1
</label>
<label class="checkbox inline">
<input type="checkbox" value="option2" checked> 2
</label>
<label class="checkbox inline">
<input type="checkbox" value="option3"> 3
</label>
</div>
<div class="modal-footer">
<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-success" id="modsave">Save</button>
</div>
</div>
<a data-target="#myModal" role="button" class="btn" data-toggle="modal">
Launch demo modal</a>
找到了一种方法来执行此操作,但当您第二次进行更改并关闭模式时它会停止工作
var clone=$("#myModal .modal-body").clone();
$('#myModal').on('hidden', function () {
$("#myModal .modal-body").html(clone);
});
Jsfiddle http://jsfiddle.net/aPDVM/172/
最佳答案
现在正在工作。在克隆上使用 html 代替
var clone=$("#myModal .modal-body").html(); //instead of clone
$('#myModal').on('hidden', function () {
$("#myModal .modal-body").html(clone);
});
Jsiddle http://jsfiddle.net/aPDVM/176/
关于jquery - 撤消模式关闭时的复选框更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19538726/
我是一名优秀的程序员,十分优秀!