我一直在寻找这个问题的答案。我可以让JQuery Easyautocomplete (http://easyautocomplete.com/)处理链接,然后让它处理图像,但我似乎不能让它同时处理两者。我是JavaScript的新手。我不确定我做错了什么。
这是我的代码。
var options = {
data: [
{
"text": "Home",
"website_link": "http://easyautocomplete.com/",
"icon": "http://lorempixel.com/100/50/transport/6"
},
{
"text": "Github",
"website_link": "https://github.com/pawelczak/EasyAutocomplete",
"icon": "http://lorempixel.com/100/50/transport/6"
}
],
getValue: "text",
template: {
type: "custom",
fields: {
website_link: "website_link"
},
method: function(value, item) {
return "<a href=" website_link "><img src='" + item.icon + "' />" + value + "</a>";
}
}
};
jQuery("#loan-officer-select").easyAutocomplete(options);我在这里做错了什么?任何帮助都将不胜感激。
发布于 2020-09-06 10:32:41
检查这是否是您想要的
var options = {
data: [
{
"text": "Home",
"website_link": "http://easyautocomplete.com/",
"icon": "http://lorempixel.com/100/50/transport/6"
},
{
"text": "Github",
"website_link": "https://github.com/pawelczak/EasyAutocomplete",
"icon": "http://lorempixel.com/100/50/transport/6"
}
],
getValue: "text",
template: {
type: "custom",
method: function(value, item) {
return `<div>
<img src="${item.icon}" width="50px" height="50px" />
<a href=${item.website_link}> click me to go to ${value}</a>
</div>`;
}
}
};
jQuery("#loan-officer-select").easyAutocomplete(options);https://stackoverflow.com/questions/63479911
复制相似问题