multi lines to one line in javascript

<html>
<head>
<title>multi lines to one line in javascript</title>
</head>
<body>
<p>Click the button to test:</p>
<textarea id="demo"></textarea>
<button onclick="myFunction()">Result</button>
<script>
var text="line1\nline2";
    document.getElementById("demo").innerHTML = text;
function myFunction() {
var str = document.getElementById("demo").innerHTML; 
    var res = text.replace(/\n/g, '');
    document.getElementById("demo").innerHTML = res;
    }
</script>
</body>
</html>

Comments

Popular posts from this blog

Format date as yyyy-mm-dd using vbscript

How to write data into a excel file using vbscript

android adb command usage