Search code examples
javascriptjquerytwitter-bootstrap-3bootstrap-select

JS how right replace `&quot` on quotes


<input type="text" autocomplete="off" class="Autocomlete1" name="test">

$('.Autocomlete1').typeahead({
            ajax: {
                    url: './test.php?log=test',
                    triggerLength: 1
                  },
            updater: function(item) {
                    return item;
                },
            onSelect: function(item) {

                    return item;
                }
    });

After autocomplate in input we get nextvalue - Text &quot; TextTextText &quot; (database row have it value) but need output Text " TextTextText "

For replace &quot; on " i want make:

onSelect: function(item) {
  var text = item.text;
  var text = text.replace(/&quot;/g, '"');
  $('.Autocomlete1').val(text);
  return item;
}

But this is not working...

Tell me please how right replace &quot on quotes ?


Solution

  • if not working var text = text.replace(/&quot;/g, '\\"'); check other lines becouse it worked for me.