阱,
如果选择了选择下拉列表中的某个选项,我试图使其显示模态窗口。它确实有效,如果不使用选择中的选项我使用一个简单的按钮,但我需要从选择。
屏幕虽然改变了它的不透明度,所以我想我正在做些什么....但是错了。显然我有自己需要的bootstrap链接和脚本,也可以打开和关闭doc和html。
有什么建议吗?
谢谢youuu
html
------------------------------------------------------------------------
<select id="selectAction" data-style="btn-info" onchange="newGraph(this)">
<option value="" disabled selected>Select your option:</option>
<option value="create">Create a new graph</option>
<option value="recall">Recall a saved graph</option>
</select>
<!--Pop up window-->
<div data-toggle="modal" data-target="#popUp1"> //it works if I put this in a <button> instead a div, but then, I have to click to button to make the modal to work so it in not what I want.
<div class="modal hide fade" id="popUp1" tabindex="-1" role="dialog" aria-labelledby="popUp1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4>Creating a new graph:</h4>
</div>
<div class="modal-body">
<p>Here some text</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success">Save changes</button>
</div>
</div>
</div>
</div>
</div>
script
--------------------------------------------------------------------------------
function newGraph(element) {
if($(element).val() === 'create') {
$('.toolsHeader').show();
$('#popUp1').modal();
$('#selectAction').hide();
}
else{
return false;
}};
答案 0 :(得分:0)
从HTML中删除此onchange="newGraph(this)"
。
添加:
$('#selectAction').change(function() {
newGraph($(this));
});
到JS。