簡體   English   中英

如何將按鈕/鏈接添加到搜索結果列表中的最后一項

[英]How to add a Button/Link to the last item in a list of search results

我正在嘗試向使用JQuery Autocomplete生成的結果列表中的最后一項添加按鈕。 當前,每個列表項的創建方式如下:

create: function(item) { 
    $(this).data('ui-autocomplete')._renderItem = function (ul, item) {
    return $('<li>')
       .append('<a>' + item.label + " " + " - " + item.type +'</a>')
       .appendTo(ul);
    };

},

我想做的是,當我到達列表中的最后一個元素時,添加一個按鈕,但是我不知道該怎么做。 我將不勝感激。

您可以使用jQuery偽選擇器獲取最后一項。

$('li:last')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM