如何在文本区域的placholder上换行 [英] how to line break on placholder of text area

查看:45
本文介绍了如何在文本区域的placholder上换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在reactjs上的textarea占位符上换行

I am looking to line break on placeholder of textarea on reactjs

到目前为止,我已经尝试使用 \ n < br> nl2br \\ n 他们都不起作用

So far I have tried to use \n, <br>, nl2br, \\n and none of them worked

<Input type="textarea" name="txtarea"  placeholder="Line1  \n Line2" />

当前输出即时消息与 Line1 \ n Line2

我的目标是将它们作为

Line1 
Line2

推荐答案

换行符在< input> 元素的占位符属性中不起作用,但在< textarea> 元素.

Newlines do not work in the placeholder attribute of <input> elements, but they work for the <textarea> element.

但是,使用< input type ="textarea"> 无效的标记,并且将由浏览器替换为< input type ="text"> .

However, using <input type="textarea"> is not valid markup and will be replaced by the browser to an <input type="text">.

如果要多行输入,请改用< textarea> .

If you want multi-line input, use a <textarea> instead.

对于换行符,请在占位符中使用&#13; &#10; HTML实体,它们是换行符换行符字符:

For the newline, use the &#13; and &#10; HTML entities in your placeholder, which are the line feed and the new line characters:

<input type="text" placeholder="line&#13;&#10;line2">
<textarea placeholder="line1&#13;&#10;line2"></textarea>

这篇关于如何在文本区域的placholder上换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆