jquery.geocomplete.js
function() {
      //$(".pac-container").hide();

      var selected = '';
      // Check if any result is selected.
      if ($(".pac-item-selected")[0]) {
        selected = '-selected';
      }

      // Get the first suggestion's text.
      var $span1 = $(".pac-container:visible .pac-item" + selected + ":first span:nth-child(2)").text();
      var $span2 = $(".pac-container:visible .pac-item" + selected + ":first span:nth-child(3)").text();

      // Adds the additional information, if available.
      var firstResult = $span1;
      if ($span2) {
        firstResult += " - " + $span2;
      }

      this.$input.val(firstResult);

      return firstResult;
    }
function() {
      //$(".pac-container").hide();

      var selected = '';
      // Check if any result is selected.
      if ($(".pac-item-selected")[0]) {
        selected = '-selected';
      }

      // Get the first suggestion's text.
      var $span1 = $(".pac-container:visible .pac-item" + selected + ":first span:nth-child(2)").text();
      var $span2 = $(".pac-container:visible .pac-item" + selected + ":first span:nth-child(3)").text();

      // Adds the additional information, if available.
      var firstResult = $span1;
      if ($span2) {
        firstResult += " - " + $span2;
      }

      this.$input.val(firstResult);

      return firstResult;
    }
function ( ) { //$(".pac-container").hide(); var selected = '' ; // Check if any result is selected. if ( $ ( ".pac-item-selected" ) [ 0 ] ) { selected = '-selected' ; } // Get the first suggestion's text. var $span1 = $ ( ".pac-container:visible .pac-item" + selected + ":first span:nth-child(2)" ) . text ( ) ; var $span2 = $ ( ".pac-container:visible .pac-item" + selected + ":first span:nth-child(3)" ) . text ( ) ; // Adds the additional information, if available. var firstResult = $span1 ; if ( $span2 ) { firstResult += " - " + $span2 ; } this . $input . val ( firstResult ) ; return firstResult ; }
Get the selected result. If no result is selected on the list, then get the first result from the list.
Get the selected result . If no result is selected on the list then get the first result from the list .