jQuery UI Selectmenu 插件,在此处演示:http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/index.html
我在使用这个插件时遇到了一些问题。我将只关注仅在 IE 中发生的一种情况。
我有 html:
<label for="SearchState"></label>
<select style="width: 160px" name="SearchState" id="SearchState">
<option>CT</option>
<option>MA</option>
<option>NH</option>
</select>
和 jQuery:
$('select#SearchState').selectmenu();
在 Firefox 中这有效,但是在 IE 中我在加载时遇到错误:
"Invalid argument" - jquery 1.4.2 Line: 4618
然而,新样式的选择菜单与原始选择菜单一起出现(这是设计使然,但原始的 html 选择菜单应该被隐藏),但是当我单击一个选项时,我会遇到以下几个错误:
"this._optionList" is null or not an object - ui.selectmenu.js Line 400
知道为什么这在 IE 中不起作用吗?
ui.selectmenu.js 的第 399-401 行
_selectedOptionLi: function() {
return this._optionLis.eq(this._selectedIndex());
},
jquery-1.4.1.js 4615-4622行
name = name.replace(rdashAlpha, fcamelCase);
if ( set ) {
style[ name ] = value;
}
return style[ name ];
最佳答案
我确认了这种行为。我在 this jsfiddle 中重新创建了它. jQuery升级到1.7.2后,就没有报这些错了。在 this jsfiddle是固定版本。请注意,我还将 jQuery UI(因为 jsFiddle)升级到 jQuery UI 1.8.18,但问题出在您使用的 jQuery 版本上。我建议更新到最新(稳定)版本的 jQuery and jQuery UI和选择菜单(JavaScript 和 CSS)。
关于javascript - 在 IE 中使用 jQuery UI Selectmenu 插件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4587370/