0
(function($) {
$.widget("ui.selectmenu", {
getter: "value",
version: "1.8",
eventPrefix: "selectmenu",
options: {
transferClasses: true,
typeAhead: "sequential",
style: 'dropdown',
positionOptions: {
my: "left top",
at: "left bottom",
offset: null
},
width: null,
menuWidth: null,
handleWidth: 26,
maxHeight: null,
icons: null,
format: null,
bgImage: function() {},
wrapperElement: "<div />"
},
_create: function() {
var self = this, o = this.options;
// set a default id value, generate a new random one if not set by developer
var selectmenuId = this.element.attr('id') || 'ui-selectmenu-' + Math.random().toString(16).slice(2, 10);
// quick array of button and menu id's
this.ids = [ selectmenuId + '-button', selectmenuId + '-menu' ];
// define safe mouseup for future toggling
this._safemouseup = true;
// create menu button wrapper
this.newelement = $('<a />', {
'class': this.widgetBaseClass + ' ui-widget ui-state-default ui-corner-all',
'id' : this.ids[ 0 ],
'role': 'button',
'href': '#',
'tabindex': this.element.attr('disabled') ? 1 : 0,
'aria-haspopup': true,
'aria-owns': this.ids[ 1 ]
});
this.newelementWrap = $(o.wrapperElement)
.append(this.newelement)
.insertAfter(this.element);
// transfer tabindex
var tabindex = this.element.attr('tabindex');
if (tabindex) {
this.newelement.attr('tabindex', tabindex);
}
// save reference to select in data for ease in calling methods
this.newelement.data('selectelement', this.element);
在這個創建函數中,動態寬度是根據瀏覽器標準進行的,僅用於菜單。所以現在我想刪除菜單的寬度屬性,請給它一個解決方案。jquery element.style問題
,並請檢查看看它是如何顯示在火災錯誤下面的代碼..它是動態創建內嵌樣式寬度表示作爲element.style {}
<a class="ui-selectmenu ui-widget ui-state-default ui-selectmenu-dropdown tinydrop tradedrop ui-state-active ui-corner-top" id="ui-selectmenu-3cab43ef-button" role="button" href="#" tabindex="0" aria-haspopup="true" aria-owns="ui-selectmenu-3cab43ef-menu" style="width: 97px; " aria-disabled="false"><span class="ui-selectmenu-status">Buy</span><span class="ui-selectmenu-icon ui-icon ui-icon-triangle-1-s"></span></a>
這個寬度不是靜態的,但它會動態的,所以你的代碼將無法工作。 – user1121019