It looks like it works at http://docs.jquery.com/Plugins/Autocomplete has a highlighting method.
You can recreate this by grabbing the regexp by their highlighting method and using it to modify the results that are sent back from your ajax request to your database:
$("#example").autocomplete({ source: function(request, response) { $.ajax({ url: "search.php", dataType: "json", data: request, success: function( data ) { var regex = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + request.term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"); var result = $.map(data, function(value){ return value.replace(regex, "<strong>$1</strong>"); }); response( result ); } }); } });
It would probably be wiser to add a server side <strong> wrapper, as it will most likely already go through each of the results.
source share