【发布时间】:2015-04-14 17:40:06
【问题描述】:
我想通过 jQuery 在 textarea 中放置一个占位符,但它在 Firefox 中不起作用。
下面是我的代码:
jQuery('#orderlink_bulk').attr("placeholder","ssss /n sss");
我该怎么做?
【问题讨论】:
标签: javascript jquery html css firefox
我想通过 jQuery 在 textarea 中放置一个占位符,但它在 Firefox 中不起作用。
下面是我的代码:
jQuery('#orderlink_bulk').attr("placeholder","ssss /n sss");
我该怎么做?
【问题讨论】:
标签: javascript jquery html css firefox
在这种情况下,escape string 的正确方法是使用\n 而不是/n。
jQuery('#orderlink_bulk').attr("placeholder","ssss \n sss");
但它不适用于该线程中所说的 Firefox:
Can you have multiline HTML5 placeholder text in a <textarea>?
【讨论】:
如果您尝试制作多行占位符,则不支持,如 W3C 文档中所述 http://www.w3.org/html/wg/drafts/html/master/forms.html#the-placeholder-attribute
这在带有\n 的 Webkit 中运行良好,但在 FF 中无法运行
http://jsfiddle.net/kyqo9xh8/
【讨论】: