So here's what I already have: When a user starts typing into a text field, a "clear" button appears within the right side of the text field that resets the search. However, since the image appears within the text field, if you happen to type enough your text will start getting obscured by the image.
This raises two questions:
I have the following HTML:
<div id="container">
<img class="clear-button" title="Clear search" src="/img/clear-button.png"
onclick="clearSearch();">
<label for="search-filter">Find Foo: </label>
<input type="text" id="search-filter" />
<input type="submit" id="search-filter-button" value="Search" />
</div>
And the following JavaScript (jQuery):
$('#search-filter').on('keypress', function(e) {
if (e.which == 13) {
$('#search-filter-button').click();
}
if ($(this).val().length != 0) {
$('.search-clear-button').fadeIn(200);
}
});
For the sake of completeness, this is what the text field looks like:
Try adding padding to the right of the input box and adjusting width accordingly.