HTML:

<form action="#">
    <fieldset>
        <label>Escolha:</label>
        <select id="horizonte">
            <option value=1>1 Mês</option>
            <option value=2>2 Meses</option>
            <option value=3 selected="selected">3 Meses</option>
            <option value=6>6 Meses</option>
        </select>
    </fieldset>
</form>

JS:
$(document).ready(function () {
    $("#horizonte").selectmenu();
});

为什么选择菜单没有正确初始化?

参见JSFiddle

最佳答案

直到1.11版才将Selectmenu小部件添加为API Documentation lists



包含至少1.11版的jQu​​ery UI

$(document).ready(function () {
    $("#horizonte").selectmenu();
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<form action="#">
  <fieldset>
    <label>Escolha:</label>
    <select id="horizonte">
      <option value=1>1 Mês</option>
      <option value=2>2 Meses</option>
      <option value=3 selected="selected">3 Meses</option>
      <option value=6>6 Meses</option>
    </select>
  </fieldset>
</form>

关于javascript - jQuery选择菜单返回错误Uncaught TypeError:undefined不是函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27177465/

10-09 08:51