2015-02-24 60 views
0

如何從返回的結果中點擊網址?jQuery自動完成請點擊網址

www.mydomain.com/search?q= 數據屬性,這裏

$(function(){ 
     var currencies = [ 
     { value: 'Afghan afghani', data: 'AFN' }, 
     { value: 'Albanian lek', data: 'ALL' }, 
     { value: 'Algerian dinar', data: 'DZD' }, 
     { value: 'European euro', data: 'EUR' }, 
     { value: 'Angolan kwanza', data: 'AOA' }, 
     { value: 'East Caribbean dollar', data: 'XCD' }, 
     { value: 'Argentine peso', data: 'ARS' }, 
     ]; 

     $('#autocomplete').autocomplete({ 
     lookup: currencies, 
     minLength: 3, 
     onSelect: function (suggestion) { 
      var thehtml = '<strong>Currency Name:</strong> ' + suggestion.value + ' <br> <strong>Symbol:</strong> ' + suggestion.data; 
      $('#outputcontent').html(thehtml); 
     } 
     }); 

回答

0

試試這個:

$("#autocomplete").bind("change",function(){ 
     document.location.href = "www.mydomain.com/search?q=" + $(this).val() 
    })