JS 如何正确替换引号上的“&quot" [英] JS how right replace `&quot` on quotes
本文介绍了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 "TextTextText "
(数据库行有它的值)但需要输出 Text " TextTextText "
After autocomplate in input
we get nextvalue - Text " TextTextText "
(database row have it value) but need output Text " TextTextText "
为了在 "
上替换 "
我想要:
For replace "
on "
i want make:
onSelect: function(item) {
var text = item.text;
var text = text.replace(/"/g, '"');
$('.Autocomlete1').val(text);
return item;
}
但这不起作用...
请告诉我如何正确替换引号中的 "
?
Tell me please how right replace "
on quotes ?
推荐答案
如果不起作用 var text = text.replace(/"/g, '\\"');
检查其他线路,因为它对我有用.
if not working var text = text.replace(/"/g, '\\"');
check other lines becouse it worked for me.
这篇关于JS 如何正确替换引号上的“&quot"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文