案例:jQuery UI案例     状态:可编辑再运行    进入竖版
 运行结果 
AخA
 
1
<!doctype html>
2
<html lang="en">
3
<head>
4
  <meta charset="utf-8">
5
  <title>jQuery UI 自动完成(Autocomplete) - 远程数据源</title>
6
  <link rel="stylesheet" href="/css/jqu1.10.4/jquery-ui.min.css">
7
  <script src="/js/jqu/jquery.min1.10.2.js"></script>
8
  <script src="/js/jqu/jquery-ui.min1.10.4.js"></script>
9
  <link rel="stylesheet" href="jqueryui/style.css">
10
  <style>
11
  .ui-autocomplete-loading {
12
    background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
13
  }
14
  </style>
15
  <script>
16
  $(function() {
17
    function log( message ) {
18
      $( "<div>" ).text( message ).prependTo( "#log" );
19
      $( "#log" ).scrollTop( 0 );
20
    }
21
 
22
    $( "#birds" ).autocomplete({
23
      source: "search.php",
24
      minLength: 2,
25
      select: function( event, ui ) {
26
        log( ui.item ?
27
          "Selected: " + ui.item.value + " aka " + ui.item.id :
28
          "Nothing selected, input was " + this.value );
29
      }
30
    });
31
  });
32
  </script>
33
</head>
34
<body>
35
 
36
<div class="ui-widget">
37
  <label for="birds">鸟:</label>
38
  <input id="birds">
39
</div>
40
 
41
<div class="ui-widget" style="margin-top:2em; font-family:Arial">
42
  结果:
43
  <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
44
</div>
45
 
46
 
47
</body>
48
</html>