简体   繁体   中英

Uncaught Error: no such method 'value' for selectmenu widget instance

I've installed the 1.10 version of jQuery and I am getting this error when trying to set the value as the way I've always done so with the selectmenu widget.

Error: Uncaught Error: no such method 'value' for selectmenu widget instance

$('select.widthOpts').selectmenu('value', wDims.feet);

I also receive the same error when attempting to set the index of the selectmenu.

the below code also works fine. I am using jQuery 1.10.2 and jquery-ui 1.11.1

$('select.widthOpts').val(wDims.feet).selectmenu('refresh')

Are you aware there are two versions?

https://github.com/fnagel/jquery-ui/ (old, fork of filament groups work) https://github.com/jquery/jquery-ui/tree/selectmenu (new, official)

The new one does not have value or index methods.

Since you are getting error, I reckon you are using new version.

So you should use $('select.widthOpts').selectedIndex=index; where index is a integer value that you already know the position of the required option in selectmenu

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM