text are converto String in JS

<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <script type="text/javascript">
            /*
             var str = "        this is a  aasdf ,fasdf' asdf' asdf";
             alert(str);//
             document.write(str.replace(/(^\s*)|(\s*$)/g, ""));
             */
            function test(){
                var ta = document.getElementById('ta').value;
                alert(ta.replace(/\r\n|\n|\r/ig, "<br>"));
            }
           
        </script>
        <textarea id="ta">
        </textarea>
        <button onclick="test()">
        </button>
    </body>
</html>

你可能感兴趣的:(JavaScript,html)