Going off the example here http://jqueryui.com/demos/autocomplete/#custom-dataI'm wondering how to add a style to the ul wrapper when using _renderItem(): .data( "autocomplete" )._renderItem = function( ul, item ) { return $( "<li></li>" ) .data( "item.autocomplete", item ) .append( "<a>" + item.label + "<br>" + item.desc + "</a>" ) .appendTo( ul ); }; 解决方案 Here would be one simple way to do it, tapping into the open event:$("#auto").autocomplete({ source: /* ... */, open: function () { $(this).data("autocomplete").menu.element.addClass("my_class"); }});jQueryUI >= 1.9$("#auto").autocomplete({ source: /* ... */, open: function () { $(this).data("uiAutocomplete").menu.element.addClass("my_class"); }});menu is an internal widget that autocomplete uses.Example: http://jsfiddle.net/bx8Ye/ 这篇关于自动完成._renderItem并将类添加到包装器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-26 22:29