我尝试了几种方法,但都没有奏效。有谁知道解决这个问题的妙招?
<textarea placeholder='This is a line \n this should be a new line'></textarea>
<textarea placeholder='This is a line
should this be a new line?'></textarea> <!-- this works in chrome apparently -->
更新:它在 chrome 中不起作用。这只是文本区域的宽度。
参见: http://jsfiddle.net/pdXRx/
最佳答案
您可以在占位符属性内插入一个新行html实体
:
<textarea name="foo" placeholder="hello you Second line Third line"></textarea>
适用于: Chrome 62、IE10、Firefox 60
不适用于: Safari 11
https://jsfiddle.net/lu1s/bxkjLpag/2/
https://stackoverflow.com/questions/7312623/