这个jquery自动完成示例中的$是什么意思

时间:2014-03-28 12:12:22

标签: jquery jquery-ui autocomplete

在下面的jquery自动完成示例中,$ .ui ...是什么意思,什么是.bind正在做什么? 而且我也没有得到这个例子的绑定部分(关于它是如何工作的)。请帮忙

(这是jquery自动完成ui的直接示例)

<script>
      $(function() {
        function split( val ) {
          return val.split( /,\s*/ );
        }
        function extractLast( term ) {
          return split( term ).pop();
        }

        $( "#birds" )
          // don't navigate away from the field on tab when selecting an item
          .bind( "keydown", function( event ) {
            if ( event.keyCode === $.ui.keyCode.TAB &&     // WHAT DOES THE $ MEAN HERE
                $( this ).data( "ui-autocomplete" ).menu.active ) {
              event.preventDefault();
            }
          })
          .autocomplete({
            source: function( request, response ) {
              $.getJSON( "search.php", {
                term: extractLast( request.term )
              }, response );
            },
            search: function() {
              // custom minLength
              var term = extractLast( this.value );
              if ( term.length < 2 ) {
                return false;
              }
            },
            focus: function() {
              // prevent value inserted on focus
              return false;
            },
            select: function( event, ui ) {
              var terms = split( this.value );
              // remove the current input
              terms.pop();
              // add the selected item
              terms.push( ui.item.value );
              // add placeholder to get the comma-and-space at the end
              terms.push( "" );
              this.value = terms.join( ", " );
              return false;
            }
          });
      });
</script>

HTML:

<div class="ui-widget">
  <label for="birds">Birds: </label>
  <input id="birds" size="50">
</div>

0 个答案:

没有答案