占位符是 IE8 不支持的 HTML5 功能
使用以下
<input type="text" value="search..." onfocus="if(this.value == 'search...') this.value = '';" onblur="if(this.value == '') this.value = 'search...';" />
使用 jQuery
<input type="text" class="my-input" value="" />
<script type="text/javascript">
$(document).ready(function () {
$('.my-input').val('search...');
$('.my-input').focus(function () {
if (this.value == 'search...') this.value = '';
});
$('input.my-input').blur(function () {
if (this.value == '') this.value = 'search...'
});
});
/*
here I assumed a class
.my-input
you can use input#id or input.className or other selector
better you give the code of your text-box or entire form so that I can give you the exact selector
*/
</script>