📅  最后修改于: 2020-11-27 02:01:08             🧑  作者: Mango
jQuery UI Selectmenu用于扩展本机HTML select元素的功能。它提供了行为和外观方面的自定义功能,远远超出了本机选择的限制。
jQuery UI Selectmenu小部件提供对select元素的适当替换,并充当原始select元素的代理,控制原始select元素的状态以进行表单提交或序列化。
让我们以一个简单的示例来演示Selectmenu的功能。
jQuery UI Selectmenu - Default functionality
以下是可与该方法一起使用的不同选项的列表。
Option | Description |
---|---|
appendTo | It is used to append the menu. Its default value is NULL. |
disabled | If you set this option to true, it disables the Selectmenu. Its default value is FALSE. |
icons | This option is used to specify a button. |
position | It identifies the position of the menu in relation to the associated button element. |
width | It specifies the width of the menu in pixels. Its default value is NULL. |
使用指定的禁用选项初始化选择菜单:
让我们以一个示例来演示上面的表选项。以下示例在jQuery UI Selectmenu示例中指定如何使用Disabled选项。
$( ".selector" ).selectmenu({
disabled: true
});
有两种方法可以使用选项“禁用”:
1)获取禁用选项:
var disabled = $( ".selector" ).selectmenu( "option", "disabled" );
1)设置禁用选项:
$( ".selector" ).selectmenu( "option", "disabled", true );
在下面的示例中,我们使用set方法:
让我们以一个示例来演示selectmenu()的用法。
jQuery UI Selectmenu - Default functionality
以下是可与此jQueryUI Selectmenu方法一起使用的不同操作(方法)的列表。
Action | Description |
---|---|
close | This method is used to close the menu. It does not accept any argument. |
destroy | It is used to remove the Selectmenu functionality completely and return the element back to its pre-init state. It does not accept any argument. |
disable | It is used to disable the Selectmenu functionality. It does not accept any argument. |
enable | It is used to enable the Selectmenu. It does not accept any argument. |
instance | This method retrieves the instance object of Selectmenu. It does not accept any argument. |
menuWidget | It returns the jQuery object containing the menu element. It does not accept any argument. |
open | It is used to open the menu. It does not accept any argument. |
option | It gets an object having the key/value pairs specifying the current Selectmenu options hash. |
refresh | It is used to parse the original element and re-render the menu. It does not accept any argument. |
widget | It returns a jQuery object having the button element. |