双引号 和单引号 互转页面 ,单引号变双引号,双引号变单引号

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  

<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>text</title>  
</head>  
  
<body>
	<h1>单引号变双引号,双引号变单引号</h1>
  <textarea id="changeContent"></textarea style="    width: 423px; height: 217px;">
  <button class ='button' onclick="change()">修改
    
  </button>
  
</body>
</html>  
<script>  
function change(){
  var text = $("#changeContent").val();
 text = text.replace(/'/g,'@');   //英文单引号变&d
 text = text.replace(/"/g,"%");  
   text = text.replace(/@/g,'"');  
   text = text.replace(/%/g,"'");
  $("#changeContent").val(text);
}


</script>  

猜你喜欢

转载自blog.csdn.net/chenzhenguo123/article/details/79713531