带有水印提示和提交值的输入文本框
问题描述:
我有一个html输入框来输入用于运行PHP脚本的值。 该值也可以使用URL和GET传递。带有水印提示和提交值的输入文本框
现在我想在我的文本框中有一个水印提示。 我用从这位先生代码: http://www.drewnoakes.com/code/javascript/hintTextbox.html
它工作正常,只是如果我输入一个值,并提交文本框不显示值,但默认暗示。我希望看到价值。 我该怎么做?
下面是部分代码:
<form method="get" action='index.php'>
<input type="text" name='q' SIZE="50" value="search for anything here" class="hintTextbox">
</form>
<?php
$Input = "";
if (isset($_GET['q'])) $Input = $_GET['q'];
try {
script($Input);
}
catch (Exception $e) {
print $e->getMessage();
}
?>
答
你可以在浏览器的新用户占位符属性或placeholder jquery plugin
<form method="get" action='index.php'>
<input type="text" name='q' SIZE="50" placeholder="search for anything here" class="hintTextbox">
</form>
的说插件,点击这里:https://github.com/mathiasbynens/Placeholder-jQuery-Plugin – Matijs 2011-04-24 09:24:07
和这个:http://webcloud.se/code/jQuery-Placeholder/不错;) – 2011-04-24 09:25:58
非常感谢。这工作得很好。 – tucson 2011-04-24 10:34:24