jQuery UI如何组合类别标题、粗体匹配字符串和标签描述?

jQuery UI如何组合类别标题、粗体匹配字符串和标签描述?,jquery,Jquery,我正试图建立一个自动完成的分类标题,黑体匹配字符串和标签描述 下面是一个在建议中使用类别标题和粗体匹配字符串自动完成的示例 下面是一个带有标签描述的自动完成示例 我是否可以合并这3个功能?在monkeypathautocomplete函数中的标签后追加说明 function monkeyPatchAutocomplete() { // Don't really need to save the old fn, // but I could c

我正试图建立一个自动完成的分类标题,黑体匹配字符串和标签描述

下面是一个在建议中使用类别标题和粗体匹配字符串自动完成的示例

下面是一个带有标签描述的自动完成示例


我是否可以合并这3个功能?

在monkeypathautocomplete函数中的标签后追加说明

function monkeyPatchAutocomplete() {
            // Don't really need to save the old fn, 
            // but I could chain if I wanted to
            var oldFn = $.ui.autocomplete.prototype._renderItem;

            $.ui.autocomplete.prototype._renderItem = function (ul, item) {
            item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) +
                ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
            return $("<li></li>")
                .data("item.autocomplete", item)
                .append("<a>" + item.label + "</a><br><a><i>" + item.desc + "</i></a>")
                .appendTo(ul);
            };
        }
函数monkeyPatchAutocomplete(){
//真的不需要去救老fn,
//但是如果我想的话我可以锁链
var oldFn=$.ui.autocomplete.prototype.\u renderItem;
$.ui.autocomplete.prototype.\u renderItem=函数(ul,项目){
item.label=item.label.replace(新的RegExp((?![^&;]+;)(?!)(?![^&;]+;),“gi”),“$1”;
返回$(“
  • ”) .data(“item.autocomplete”,item) .append(“