js input onBlur not worked when the page onload
The link example is here: http://jsfiddle.net/fxr5p/ How to make if value is empty, onload work onblur
function? show type your keyword
, then click the input part, onblur
word disapear? Thanks.
<input type="text" value="" id="search" name="Search" onblur="if(this.value=='') this.value='type your keyword';" onfocus="if(this.value=='type your keyword') this.开发者_如何学编程value='';">
<script>
document.body.onload = function ()
{
document.getElementById("search").value = "type your keyword";
}
</script>
Try this:
<input type="text" value="type your keyword" id="search" name="Search" onblur="if(this.value=='') this.value='type your keyword';" onfocus="if(this.value=='type your keyword') this.value='';">
I think you're almost there, just use value="type your keyword"
.
精彩评论