Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is the solution I went with:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt; &lt;script type='text/javascript' src='http://code.jquery.com/jquery-1.6.2.js'&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.js"&gt;&lt;/script&gt; &lt;style type='text/css'&gt; .srchHilite {background-color: yellow;} &lt;/style&gt; &lt;script type='text/javascript'&gt; $(document).ready(function(){ var termTemplate = "&lt;span class='ui-autocomplete-term'&gt;%s&lt;/span&gt;"; $("#tags").autocomplete({ source: function(request, response) { $.getJSON("livesearch.php", request, function(data, status, xhr ) { var newmatchArry = new Array(); var matchArry = data.slice (); var srchTerms = $.trim (request.term).split (/\s+/); //--- For each search term, remove non-matches. $.each (srchTerms, function (J, term) { var regX = new RegExp (term.value, "i"); matchArry = $.map (matchArry, function (item) { return regX.test (item) ? item : null; } ); } ); response(matchArry); }); }, open: function (event, ui) { /*--- This function provides no hooks to the results list, so we have to trust the selector, for now. */ var resultsList = $("ul.ui-autocomplete &gt; li.ui-menu-item &gt; a"); var srchTerm = $.trim ( $("#tags").val () ).split (/\s+/).join ('|'); //--- Loop through the results list and highlight the terms. resultsList.each ( function () { var jThis = $(this); var regX = new RegExp ('(' + srchTerm + ')', "ig"); var oldTxt = jThis.text (); jThis.html (oldTxt.replace (regX, '&lt;span class="srchHilite"&gt;$1&lt;/span&gt;') ); } ); } } ); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input id="tags"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload