title: Jquery autocomplete highlight text
body: <p>I want to make matched text in string bold in autocomplete I got great help from this <a href="https://stackoverflow.com/questions/2435964/jqueryui-how-can-i-custom-format-the-autocomplete-plug-in-results">link</a>.</p>
  
  <p>This doesnt it for single word or word which are in sequence I want to make words bold no matter in which order they are.</p>
  
  <p>I want to make each and every word matching in the string bold</p>
  
  <pre><code>var t = "Cadbury Gems 100gm Tasty";
  var wordArr = 'gems tasty'.toLowerCase().replace(/\b[a-z]/g, function (letter) {
      return letter.toUpperCase();
  }).split(' ');
  $.each(wordArr, function (i) {
      console.log(wordArr[i]);
      var re = new RegExp("^" + wordArr[i], "i");
      t = t.replace(re, "&lt;span style='font-weight:bold;color:Blue;'&gt;" + wordArr[i] + "&lt;/span&gt;");
  
  })
  console.log(t);
  var li = $("&lt;li&gt;&lt;/li&gt;")
  //.data("item.autocomplete", item)
  .append("&lt;a style='text-align:left'&gt;" + t + "&lt;/a&gt;")
      .appendTo($('#ul'));
  </code></pre>
  
  <p>MY <a href="http://jsfiddle.net/2bFL2/" rel="nofollow noreferrer">Fiddle</a></p>
  
  <p>I tried with <code>$.each</code> But doesnt work. Any ideas.</p>