<!doctype html>
<html>
<head>
<!--声明当前页面的编码集:charset=gbk,gb2312(中文编码),utf-8国际编码-->
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<script type="text/javascript" src=""></script><!--引入的js src是引入的js样式路径-->
<link rel="stylesheet" href="" /><!--引入的css页面的样式 href是引入的css样式路径-->
<!--当前页面的三要素-->
<title>字符串拼接</title>
<meta name="Keywords" content="关键词,关键词">
<meta name="description" content="">
<!--css,js-->
<style type="text/css">
*{margin:0;padding:0;font-family:"微乳雅黑";font-size:14px;}
body{background:#2D2D2D;}
input{color:#fff}
.w_cont .w_neirong{width:80%;height:250px;background:#fff;margin:10px auto;border-radius:10px;}
.w_cont .w_retuse{width:80%;height:250px;background:#fff;margin:0 auto;margin-top:-25px;border-radius:10px;}
input{background:#308796;border:1px solid #308796;border-radius:5px;width:100px;height:35px;}
p{margin:30px auto;text-align:center;color:#fff;}
textarea{border:3px solid #6A6A6A;width:100%;height:250px;border-radius:10px;padding:10px;}
</style>
</head>
<body style="width:100%;height:100%">
<div class="w_cont">
<div class="w_neirong" id="w_neirong">
<textarea class="w_target" id="target"></textarea>
</div>
<p>
<input type="button" value="转双引号" onclick="shunyinghao()"/>
<input type="button" value="转双引号为一行" onclick="wfshunyinghao()"/>
<p>
<div class="w_retuse" id="w_retuse">
<textarea class="w_result" id="result"></textarea>
</div>
</div>
<script>
function dom(id){
return document.getElementById(id);
}
//转多行
function shunyinghao(){
var value =dom("target").value;
value=value.replace(/\"/g, "'");
var s = value.split("\n"),
len = s.length;
for (var i = 1; i <= len; i++) {
if ("" != s[i - 1]) {
s[i - 1] = "str+=\"" + s[i - 1]+"\";";
}
}
dom("result").value = s.join("\n");
}
//转一行
function wfshunyinghao(){
var value =dom("target").value;
value="str+=\"" + value.replace(/\"/g, "'").replace(/\s/g, "")+"\";";
dom("result").value =value;
}
</script>
</body>
</html>