简体   繁体   English

我需要使用JS在HTML的输入字段中打印abc \\

[英]I need to print abc\ in input field of HTML using JS

I need to print abc\\ in input field of HTML using JS. 我需要使用JS在HTML的输入字段中打印abc\\

<p id="pid"></p>
<script>
var a ='abc\';//this is required output of my input, not abc\\
document.getElementById("pid").innerHTML=a.replace("\","\\");
</script>

This is showing as an unexpected error. 这显示为意外错误。 So, how I can get this value ( abc\\ ) in input, or any other place using document ? 那么,如何在输入或使用document任何其他位置获取此值( abc\\ )?

您应该使用\\\\来转义\\

var a ='abc\\';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM