我想更改搜索框中的文本值,例如说“Awesome Search”。我知道可以用Jquery完成,但我无法实现它的工作。你能帮忙吗?我怎样才能改变这与jquery?
请注意,这是由WordPress提供的默认设置,对于我来说,要编辑文件以将内容与行为分开是很困难的,所以我需要Jquery覆盖默认设置。迄今为止提供的两个答案似乎并没有这样做。
<input type="text"
onblur="if (this.value == '') {this.value = 'To search, type and hit enter';}"
onfocus="if (this.value == 'To search, type and hit enter') {this.value = '';}"
id="s"
name="s"
value="To search, type and hit enter"
class="text_input">
*当你想让它显示“Awesome Search”时? – 2011-06-07 02:28:33
@ Box9哎呀。抱歉。我希望文本在搜索框中可见,而访问者不必将光标移动到搜索框中。 – mjmitche 2011-06-07 03:25:24