Skip to content Skip to sidebar Skip to footer

Change Image Src With Jquery Autocomplete

I have this jQuery autocomplete function that works terrifically. But, I wanna make it so that when the user clicks on one of the choices from the drop down box and the value is th

Solution 1:

I don't know if this will really work but:

 $('#team').autocomplete(data)
      .result(function(event, item) {
          $('img#team_wallpaper').attr("src", "mlb/" +item.text+ ".png");
      });

See: http://docs.jquery.com/Plugins/Autocomplete#API_Documentation at the very bottom "Search Page Replacement"

Solution 2:

You are catching the onchange of the text field before the autocomplete can update it. you can try attaching to the select event on the autocompleat

$("#team").autocomplete({ 
   source: data, 
   select: function(event,ui){alert(ui.item.value)}})

Post a Comment for "Change Image Src With Jquery Autocomplete"