简体   繁体   English

选中选择选项后将触发jQuery对话框

[英]jQuery Dialog Box To Fire Once Select Option Is Selected

I'm trying to open a dialog box once any option is selected from the dropdown list. 从下拉列表中选择任何选项后,我试图打开一个对话框。 Here is my jQuery: 这是我的jQuery:

$(document).ready(function() {

$( "#dialogbox" ).dialog({ modal: true, autoOpen: false }); 
    $( "#dropdown" ).selected(function() {
        $( "#dialog" ).dialog( "open" );
        $( "#dialogbox" ).toggle( "puff" );
    });
});

I think the problem is ".selected(function()" I've tried .change, .click, and none of them seem to fire the dialog box. I've been through the API documentation, but couldn't find how to do this for a dropdown. I'm new to this, and would appreciate any help. 我认为问题是“ .selected(function()”),我尝试了.change,.click,但似乎都没有触发该对话框。我已经浏览了API文档,但找不到如何我是新手,不胜感激。

Here is my fiddle 这是我的小提琴

Try this: 尝试这个:

$("#dropdown").change(function(){
    $("#dialogbox").dialog();
});

I suppose you have an element with #dialogbox id in your html somewhere otherwise the code won't show anything. 我想您在html的某个地方有一个带有#dialogbox id的元素,否则代码将不会显示任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM