Javascript Form How to - Control TextArea wrap mode








Question

We would like to know how to control TextArea wrap mode.

Answer


<!--from   ww w.  j  ava  2s.  co m-->


   
    
<html>
<body>
    <textarea id="myTextArea1" rows="4">Long text Long text Long text </textarea>
    <textarea id="myTextArea2" rows="4">Long text Long text Long text </textarea>
    <textarea id="myTextArea3" rows="4">Long text Long text Long text </textarea>
    <script language="JavaScript">
        document.all.myTextArea1.wrap = "soft";
        document.all.myTextArea2.wrap = "hard";
        document.all.myTextArea3.wrap = "off";
        console.log(document.all.myTextArea3.wrap);
    </script>
</body>
</html>

The code above is rendered as follows: