javascript - jQuery UI 选择菜单错误

标签 javascript jquery html jquery-ui

我正在尝试实现 jQuery UI SelectMenu,但我在浏览器控制台中一次又一次地出现相同的错误。

这是 HTML 代码

<select name="files" id="files">
  <optgroup label="Scripts">
    <option value="jquery">jQuery.js</option>
    <option value="jqueryui">ui.jQuery.js</option>
  </optgroup>
  <optgroup label="Other files">
    <option value="somefile">Some unknown file</option>
    <option value="someotherfile">Some other file with a very long option text</option>
  </optgroup>
</select>

和 Javascript/jQuery 代码

$(function() {

$( "#files" ).selectmenu();

});

它与 jQuery UI 网站相同,但对我不起作用。

这是错误:

jquery-3.0.0.js:9779 Uncaught TypeError: elem.getClientRects is not a function

希望大家有想法。

谢谢

最佳答案

jquery 版本 >= 3.0 与较旧的 jquery-ui 或可能是最新版本存在兼容性问题。我建议您包含 jquery-migrate-3.0.js 并看看这是否有效。

根据release doc :

To assist with upgrading, we have a brand new 3.0 Upgrade Guide. And the jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code. Your feedback on the changes will help us greatly, so please try it out on your existing code and plugins.

In addition, we’ve got the release for jQuery Migrate 3.0. We highly recommend using this to address any issues with breaking changes in jQuery 3.0. You can get those files here:

jquery-migrate-3.0.js

jquery-migrate-3.0.min.js

Fiddle DEMO with jquery migrate 3.0 included

关于javascript - jQuery UI 选择菜单错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38136205/

相关文章:

python - Django:更改由 {{variable}} 生成的文本字符串中间的 HTML 模板字体

javascript - Fancybox 2 和 Swipe Slider 不能一起使用

javascript - 无法在 Android 应用程序中访问大于 10mb 的文件

javascript - nodejs 中的多级 Promise

javascript - 即使在 CSS 中设置了宽度后,主体宽度仍在扩大

javascript - 什么时候 'this' 不是定义函数的实例?

javascript - 关于菜单栏显示图标

javascript - React根组件不会加载整个index.html

javascript - node scripts/install.js 没有指向正确的正确 url

javascript - 使用 jQuery 获取元素的父元素