[英]modal popup in javascript
I have a checkbox, which is inside a modal popup div.I want the check box value when the checkbox is checked and want to place the value to a div which is outside the modal popup box.Please help me to find a solution. 我有一个复选框,位于模式弹出框div中。我希望复选框选中时的复选框值,并希望将该值放置在模式弹出框之外的div中。请帮助我找到解决方案。 Please find the code below 请在下面找到代码
<div class="container">
<div id="test"></div>
<h2>Modal popup</h2>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-body">
<input type="checkbox" class="ck " id="mealstotal" value="12">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
Please find below mentioned solution. 请找到以下提到的解决方案。 This will help you. 这将为您提供帮助。
$(document).on('change','#item',function(){ if($(this).prop('checked') == true){ $('#result').html($(this).val()); }else{ $('#result').html(''); } });
div {border:1px solid red; width:100%; padding:10px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="checkbox" name="item" id="item" value="1" /> Checkbox <div id="result"></div>
Let me know if it not works. 让我知道是否有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.