开发者问题收集

语义 UI 下拉菜单不起作用

2014-12-22
5557
<!DOCTYPE html>

<!--[if IE 7]>                  <html class="ie7 no-js" lang="en">     <![endif]-->
<!--[if lte IE 8]>              <html class="ie8 no-js" lang="en">     <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="not-ie no-js" lang="en">  <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">


    <script>

    </script>
</head>
<body>

<select class="ui dropdown search selection" id="search-select">
  <option value="">State</option>
  <option value="AL">Alabama</option>
  <option value="AL">Alabama</option>
  <option value="AK">Alaska</option>
  <option value="AZ">Arizona</option>
  <option value="AR">Arkansas</option>
  <option value="CA">California</option>
  <option value="OH">Ohio</option>
  <option value="OK">Oklahoma</option>
  <option value="OR">Oregon</option>
  <option value="PA">Pennsylvania</option>
  <option value="RI">Rhode Island</option>
  <option value="SC">South Carolina</option>
  <option value="SD">South Dakota</option>
  <option value="TN">Tennessee</option>
  <option value="TX">Texas</option>
  <option value="UT">Utah</option>
  <option value="VT">Vermont</option>
  <option value="VA">Virginia</option>
  <option value="WA">Washington</option>
  <option value="WV">West Virginia</option>
  <option value="WI">Wisconsin</option>
  <option value="WY">Wyoming</option>
</select>





    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>


    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.3.2/semantic.min.js"></script>
        <link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.3.2/semantic.min.css" rel="stylesheet">



<script>
$(document).ready(function(){
    $('#search-select').dropdown();
});
    </script>
</body>
</html>

我正在尝试实现带搜索的语义 UI 下拉菜单,下拉框显示但点击时不显示任何内容。我认为这是 JavaScript 的问题,但不确定如何解决。

1个回答

1:使用较新版本的 jQuery:

<script src="https://code.jquery.com/jquery-1.11.2.js"></script>

2:每个元素仅实例化一次

这似乎解决了问题。问题的关键在于您链接的 jQuery 版本较旧。

Ted
2014-12-22