我在经典asp的for循环中动态构建一个带有少量标签和文本框的表单,
代码:
<td>
<input type="text"" name="<%=xtinct.item(i).getAttribute("col1")%>"/>
</td>
我需要将应该隐藏的默认文本放在 onfocus 上。我不能使用“PlaceHolder”属性。我该怎么做?请提出一些答案。
我在经典asp的for循环中动态构建一个带有少量标签和文本框的表单,
代码:
<td>
<input type="text"" name="<%=xtinct.item(i).getAttribute("col1")%>"/>
</td>
我需要将应该隐藏的默认文本放在 onfocus 上。我不能使用“PlaceHolder”属性。我该怎么做?请提出一些答案。
使用占位符
<input type="text"" name="<%=xtinct.item(i).getAttribute("col1")%>" placeholder="default text" />
你需要为 IE 使用一些 jQuery。阅读这篇文章 -
http://dipaksblogonline.blogspot.in/2012/02/html5-placeholder-in-ie7-and-ie8-fixed.html
编辑:
这将适用于所有浏览器 -
<input type="text" value="Your email" onblur="if(this.value == '') { this.value='Your email'}" onfocus="if (this.value == 'Your email') {this.value=''}">
您可以使用 HTML5 占位符属性:
http://davidwalsh.name/html5-placeholder
或者你可以使用 JavaScript。jQuery 很容易连接起来。有很多教程。谷歌“使用 jQuery 的默认输入字段文本”。
像这样:
<form name="f">
<textarea name="<%=xtinct.item(i).getAttribute("col1")%>" onFocus="this.value=''">
Enter your text here...
</textarea>
</form>