2012-06-11 44 views
1

嘿,我需要添加HTML內容之前和之後使用自動完成動態生成的列表........以下是我的代碼片段。 .i已嘗試附加,前置到li但沒有運氣......並且我還需要將列表中的項目數限制爲最大值5.我該怎麼做?自定義JQuery自動完成添加列表前後的靜態HTML內容

$(document).ready(function() { 
       $("#autocomplete").autocomplete({ 

        source: source, 
        select: function (event, ui) { 

         window.location.href = ui.item.value; 
         this.autohide(); 
        } 

       }) 
       .data("autocomplete")._renderItem = function (ul, item) { 
        $("<li></li>") 
       .data("item.autocomplete", item) 
       .append("<a>" + "<img src='" + item.imgsrc + "' /><strong>" + item.label + "</strong></a>") 
       .appendTo(ul)       
       }; 


      }); 

回答

2

看看這個jqfaq.com鏈接。這將解釋如何在自動完成結果列表的開始和結束處添加文本。

請查看列表中可能感興趣的其他自動完成相關常見問題解答。

相關問題