js 小说格式整理

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="智能社 - zhinengshe.com" />
<meta name="copyright" content="智能社 - zhinengshe.com" />
<title>智能社 - www.zhinengshe.com</title>
<style>
body{ text-align:center;}
</style>
<script>
window.onload = function(){
    var oText1 = document.getElementById("txt1");
    var oText2 = document.getElementById("txt2");
    var oBtn   = document.getElementById("btn1");    
    
    
    oBtn.onclick = function(){
        //oText2.value = oText1.value.replace(/^/mg,"    ").replace(/$/mg,"
");
        oText2.value = oText1.value.replace(/^/mg,"    ").replace(/$/mg,'
');
    };
};

</script>
</head>

<body>

<textarea id="txt1" rows="15" cols="80"></textarea><br />

<input id="btn1" type="button" value="整理" /><br />
<textarea id="txt2" rows="15" cols="80"></textarea>

</body>
</html>
原文地址:https://www.cnblogs.com/heboliufengjie/p/4750130.html