你可以在一个多行的 HTML5 占位符文本<textarea> ? - Can you have multiline HTML5 placeholder text in a <textarea>?

2021/11/30 05:29
阅读数 0

问题:

I have ghost text in textfields that disappear when you focus on them using HTML5's placeholder attribute:当您使用 HTML5 的占位符属性关注它们时,我在文本字段中有幻影文本会消失:

<input type="text" name="email" placeholder="Enter email"/>

I want to use that same mechanism to have multiline placeholder text in a textarea, maybe something like this:我想使用相同的机制在 textarea 中包含多行占位符文本,可能是这样的:

<textarea name="story" placeholder="Enter story\n next line\n more"></textarea>

But those \\n s show up in the text and don't cause newlines... Is there a way to have a multiline placeholder?但是那些\\n出现在文本中并且不会导致换行......有没有办法拥有多行占位符?

UPDATE : The only way I got this to work was utilizing the jQuery Watermark plugin , which accepts HTML in the placeholder text:更新:我让它工作的唯一方法是使用jQuery Watermark 插件,它接受占位符文本中的 HTML:

$('.textarea_class').watermark('Enter story<br/> * newline', {fallback: false});

解决方案:

参考: https://stackoom.com/en/question/UAFD
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部