转义符输入的转换

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="text" id="input">  
		<input type="text" id="b">
		<button  onclick="trans()">转换</button>
		<script>
			
			function trans(){
				var a = document.querySelector('#input')
				var b = document.querySelector('#b')				
				const obj = {
					value :a.value,
					value2:b.value
				}
				console.log(JSON.stringify(obj).replace(/\\\\/ig,"\u005c"),"stringify")
			}
		</script>
	</body>
</html>
posted @ 2020-08-04 22:50  橙云生  阅读(258)  评论(0编辑  收藏  举报