我怎样才能使 jQuery Autocomplete 显示带有图像的结果,而不是 PHP?

发布于 2024-08-21 17:12:43 字数 331 浏览 3 评论 0原文

我正在实现 jQuery 自动完成并希望显示带有关联图像的结果。每个图像的名称与自动完成字段的预测结果相同。即,如果有人输入“braz”,则会出现“brazil”,旁边会内嵌 brazil.jpg。我在执行此操作时遇到困难。

如果有人能指出我正确的方向,我将不胜感激。顺便说一句,我正在使用 Jorn 的版本

我也有兴趣使用较小版本的自动完成功能,但只找到了 Drew Wilson 的,根本无法使用它。

I am implementing jQuery Autocomplete and wish to display results with an associated image. Each image has the same name as the predicted result of the autocomplete field. i.e. If someone types "braz" then "brazil" appears with brazil.jpg inline beside it. I'm having trouble implementing this.

If anyone can point me in the right direction I'd appreciate it. By the way, I'm using Jorn's version.

Am also interested in using smaller versions of autocomplete, but have only found Drew Wilson's and couldn't manage to work it at all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨与橙与城 2024-08-28 17:12:43

查看此演示页面上的#suggest4formatItemformatResult 函数用于使结果和项目显示不同。

function formatItem(row) {
    return row[0] + " (<strong>id: " + row[1] + "</strong>)";
}
function formatResult(row) {
    return row[0].replace(/(<.+?>)/gi, '');
}

// apply the format functions using the options provided.
$("#country").autocomplete('getdata.jsp', { 
    formatItem: formatItem,
    formatResult: formatResult
};

Look at #suggest4 on this demo page. The formatItem and formatResult functions are used to make the result and the item appear different.

function formatItem(row) {
    return row[0] + " (<strong>id: " + row[1] + "</strong>)";
}
function formatResult(row) {
    return row[0].replace(/(<.+?>)/gi, '');
}

// apply the format functions using the options provided.
$("#country").autocomplete('getdata.jsp', { 
    formatItem: formatItem,
    formatResult: formatResult
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文