javascript中用于自动完成搜索的img标记

javascript中用于自动完成搜索的img标记,javascript,jquery,autocomplete,Javascript,Jquery,Autocomplete,我正在设计一个自动完成搜索,将有文本和图像的结果(工作良好)。但是,由于标准图像缓存,我的图像模糊。所以我想知道是否有可能在javascript中调整图像的大小,使它们看起来整洁和小 下面是我使用img标记的javascript 有人能帮我吗?谢谢 .data('autocomplete')._renderItem = function(ul, item) { return $('<li>') .data('item.autocomplete', item) .ap

我正在设计一个自动完成搜索,将有文本和图像的结果(工作良好)。但是,由于标准图像缓存,我的图像模糊。所以我想知道是否有可能在javascript中调整图像的大小,使它们看起来整洁和小

下面是我使用img标记的javascript

有人能帮我吗?谢谢

.data('autocomplete')._renderItem = function(ul, item) {
   return $('<li>')
   .data('item.autocomplete', item)
   .append("<a>"+"<img src ='/account/"+item.id+"/icon/preview'/>" + item.label+"</a>")
   .appendTo(ul); 
.data('autocomplete')。\u renderItem=函数(ul,项目){
返回$(“
  • ”) .data('item.autocomplete',item) .append(“+”+项.标签+”) .附录(ul);
  • 只需为图像标签添加CSS属性,或通过类似脚本的方式进行更改即可

    image.style.width='50%';
    image.style.height='auto';
    

    通过这样做,您可以保持图像的分辨率。这样它就不会丢失其质量。

    我希望这段代码能帮助您,这里我使用了带有内联风格的jquery UI

    $.ui.autocomplete.prototype._renderItem = function(ul, item) {
    return $("<li></li>")
    .data("item.autocomplete", item)
    .append("<a><img src='/account/"+item.id + "/icon/preview' style='position:relative; top:30px;width:50px;height:50px;' />"+item.label+ "</a>").appendTo( ul );
    };}
    
    $.ui.autocomplete.prototype.\u renderItem=函数(ul,项目){
    返回$(“
  • ”) .data(“item.autocomplete”,item) .append(“+item.label+”).appendTo(ul); };}