(function($) { $(function() { $('#s').autocomplete({ source: '/wp-content/plugins/search-autocomplete/includes/tags.php', minLength: 2, select: function(event, ui) { if (ui.item.url !== 'none') { location = ui.item.url; } else { $(this).val(ui.item.label); } } }); }); })(jQuery);