[英]jQuery UI Combobox: How can I add a class to autocomplete div
I use the jQuery combobox plugin: 我使用jQuery combobox插件:
https://jqueryui.com/autocomplete/#combobox https://jqueryui.com/autocomplete/#combobox
My JS: 我的JS:
$(function() {
$( "#combobox" ).combobox();
$( "#toggle" ).click(function() {
$( "#combobox" ).toggle();
});
});
My goal is to add a custom class to the autocomplete div in order to individually style the autocomplete dropdown. 我的目标是向自动完成div中添加自定义类,以便分别设置自动完成下拉菜单的样式。 I already tried the following, but this is not working:
我已经尝试了以下方法,但这不起作用:
$( "#combobox" ).combobox().autocomplete("widget").addClass('my-custom-autocomplete-class');
Try This, As per selected value class add to combobox write css for each option mention in drop down 尝试此操作,根据选定的值类别添加到下拉列表中下拉列表中提到的每个选项的css中
$(function($) {
$( 'select[id=combobox]' ).on("change",function() {
var dynaminClass = $(this).val();
console.log(dynaminClass);
$(this).attr('class', dynaminClass);
})
}) })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.