在变量中获取Jquery UI Selectmenu值

时间:2016-11-19 17:37:57

标签: jquery jquery-ui

如何在变量中获取jquery ui selectmenu值? 我正在尝试使用此代码:

    <link href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css" rel="stylesheet" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>


    <select name ="option" id="firstOption">
    <option value="0">First Option</option>
    <option value="1">Second Option</option>
    </select>
 $("#firstOption").selectmenu( change: function(event, data) {
        var chartBkgColor=$(this).val();
        if (chartBkgColor==0){
            alert ("0");
        }else if (chartBkgColore==1){
            alert ("1");
        });

1 个答案:

答案 0 :(得分:0)

我想通了

<head>
    <link href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css" rel="stylesheet" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<head>
<body>
    <select name ="option" id="firstOption">
    <option value="0">First Option</option>
    <option value="1">Second Option</option>
    </select>
<javascript>
 $("#firstOption").selectmenu( change: function(event, data) {
        var chartBkgColor=$('#firstOption').val();
        if (chartBkgColor==0){
            alert ("0");
        }else if (chartBkgColore==1){
            alert ("1");
        });
</javascript>