JQuery自动完成显示结果在无序列表中?

时间:2014-03-03 11:58:45

标签: javascript jquery asp.net autocomplete

我想在无序列表中显示结果JQuery自动完成结果,如何创建它。 Java脚本代码

$("#seachbox").autocomplete("result.ashx", {
            width: 200,
            formatItem: function (data, i, n, value) {

          return =""; //---- ?
},

html

<ul>
    <li>
        <a href='#'><img src='It_img/studentpic.jpg' '/> Name of student</a> 
    </li>
</ul>

2 个答案:

答案 0 :(得分:1)

jQuery UI Api中专门为此设计的扩展插件(扩展点)很少

<强> _renderMenu:

 _renderMenu: function( ul, items ) {
    var that = this;
    $.each( items, function( index, item ) {
        that._renderItemData( ul, item );
    });
 //after list population is complete, add some additional css classes or operations like this below
 $( ul ).find( "li:odd" ).addClass( "odd" );
}

控制构建窗口小部件菜单的方法。该方法传递一个空的<ul>和一个与用户类型的术语匹配的项目数组。创建单个<li>元素应委托给_renderItemData()

更多信息:http://api.jqueryui.com/autocomplete/#method-_renderMenu

快乐编码:)

答案 1 :(得分:0)

  $(function() {
    var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme"
    ];
    $( "#tags" ).autocomplete({
      source: availableTags
    });
  });

以下是链接,工作原理和示例。 http://jqueryui.com/autocomplete/#default