实现自动换行type="text"

如当值长度超过5个,就实现自动换行,可以实现吗?别说用textarea,我想问问大神们

一个脑筋急转弯对付提出这种变态要求不懂技术的傻驴老板的办法是,在页面上加上一段脚本,将text的控件替换成textarea。

lz希望你采纳。

type="text"这个就是单行文本,是没有办法实现自动换行的;如果能实现自动换行那就是多行文本了,这个用什么你也知道了;
而且就你的问题我也搜了,也没有解决办法的;

如果回答对您有帮助,请采纳

楼主可以自己开发个浏览器。。要不text肯定不支持换行的。不过用js来模拟是可以的。。

 <script>
    function checkWord(o) {
    console.log(o.value.length)
        if (o.value.length == 5) {
            var dv = document.createElement('div');
            dv.innerHTML = o.value;
            document.getElementById('words').appendChild(dv);
            o.value = '';
        }
    }
</script>
<div style="width:100px;border:solid 1px #000;">
<div id="words" style="line-height:20px"></div>
<input type="text" style="border:none;width:100px;line-height:20px;height:20px;background:#fff" onkeyup="checkWord(this)"/>
</div>
 <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Scripts/jquery-2.1.3.js"></script>
    <script type="text/javascript">
        function change()
        {
            $(":text").each(function() {
                $("<textarea rows='3' clos='5' />").val($(this).val()).insertAfter($(this));
                $(this).remove();
            });
        }
    </script>
</head>
<body>
    <input type="text" id="text1" />
    <input type="text" id="text2" value="hello world" />
    <input type="text" id="text3" />
    <input type="button" onclick="change()" value="change" />
</body>
</html>