通过jquery onselect选项打开模型窗口 [英] open a model window by jquery onchange of select option
本文介绍了通过jquery onselect选项打开模型窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过jquery onselect选项打开模型窗口?
How can I open a model window by jquery onchange of select option???
模态窗口的代码在这里:
Code for Modal window is here:
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" id="myModal" style="display:none" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
Some Contents here..
</div>
</div>
</div>
用于选择的代码在这里:
Code for Select option is here:
<select id="selectbox">
<option value="0">- Select -</option>
<option value="1">yes</option>
<option value="2">No</option>
</select>
推荐答案
首先,您需要获取 jQuery UI对话框并将其放在您的 (document).ready
处理程序中.
First you need to grab the jQuery UI dialog and put it in your (document).ready
handler.
$('#dialog-modal').dialog({
modal: true,
autoOpen: false
});
此后,您定义一个在 .change()
上说的函数,它将打开对话框:
After that, you define a function that says on .change()
it should open the dialog:
$('select').change(function () {
$('#dialog-modal').dialog('open');
});
要说它应该在'是'上打开,只需放置一个代表您的'是'选择的if语句:
To say that it should open on 'yes', just put an if statement representing your 'yes' choice:
if ($(this).val() == "1") {
//...code...
}
这篇关于通过jquery onselect选项打开模型窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文