JS 如何正确替换引号上的“&quot" [英] JS how right replace `&quot` on quotes

查看:50
本文介绍了JS 如何正确替换引号上的“&quot"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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;
                }
    });

input 中自动完成后,我们得到 nextvalue - Text &quot;TextTextText &quot;(数据库行有它的值)但需要输出 Text " TextTextText "

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

为了在 " 上替换 &quot; 我想要:

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;
}

但这不起作用...

请告诉我如何正确替换引号中的 &quot ?

Tell me please how right replace &quot on quotes ?

推荐答案

如果不起作用 var text = text.replace(/&quot;/g, '\\"'); 检查其他线路,因为它对我有用.

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

这篇关于JS 如何正确替换引号上的“&amp;quot"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆