$(function() { $('#suggestText').change() }); $('#suggestText').change(function() { $.getJSON('http://suggestqueries.google.com/complete/search?q={0}&callback=?' .replace('{0}', $(this).val()), function(data) { $('#suggestions li').remove(); $.each(data[1], function(key, val) { $('#suggestions').append('<li><a target="_blank" href="http://google.com/search?q=' + val[0].replace(/ /g, '+') + '">' + val[0] + '</li>'); }); }); });
<input type="text" id="suggestText" value="why does my" /> <ul id="suggestions"></ul>