gpt4 book ai didi

jquery - 撤消模式关闭时的复选框更改

转载 作者:行者123 更新时间:2023-12-01 04:11:51 24 4
gpt4 key购买 nike

我有一个包含 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com