Clear Input onFocus with Google Custom Search
Posted
by Wes
on Stack Overflow
See other posts from Stack Overflow
or by Wes
Published on 2010-05-20T17:56:51Z
Indexed on
2010/05/20
18:00 UTC
Read the original article
Hit count: 293
JavaScript
|google-search
I'm moving a sites search over to google custom search.
The old input for text looks like this:
<input type="text" value="Search this website..." name="s" id="searchbox" onfocus="if (this.value == 'Search this website...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search this website...';}" />
Now I need to Have the attr 'name' as 'q', like so:
<input type="text" value="Search this website..." name="q" id="searchbox" onfocus="if (this.value == 'Search this website...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search this website...';}" />
The odd thing is that when I swap the name over to q, I'm unable to clear the search box on focus. Am I missing something super easy?
© Stack Overflow or respective owner