[英]How to add a Button/Link to the last item in a list of search results
I'm trying to add a button to the last item in the list of results I am generating using JQuery
Autocomplete
. 我正在尝试向使用JQuery
Autocomplete
生成的结果列表中的最后一项添加按钮。 Currently, each list item is created like so: 当前,每个列表项的创建方式如下:
create: function(item) {
$(this).data('ui-autocomplete')._renderItem = function (ul, item) {
return $('<li>')
.append('<a>' + item.label + " " + " - " + item.type +'</a>')
.appendTo(ul);
};
}, },
What I'd like to do is when I get to the last element in the list add a button, however I can't figure out how to do that. 我想做的是,当我到达列表中的最后一个元素时,添加一个按钮,但是我不知道该怎么做。 I'd appreciate any help. 我将不胜感激。
您可以使用jQuery伪选择器获取最后一项。
$('li:last')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.