簡単で実用的なテキストボックスのフォーカスはテキストのコントロールにヒントを与えます。

580 ワード

このコードはjquery 1.3.2ベースの上開発に基づいています。jqueryファイルを導入してください。
<script type="text/javascript">
$(function(){
	var t="       ";  //t=>    
        //SearchForm=>    ;SearchContainer=>     ID  
   	$("#SearchForm [id=SearchContainer]").focus(function(){
    	if($(this).val()==t)
        	$(this).val("");
    }).blur(function(){
    	if($(this).val()!=t && $(this).val()=="")
        	$(this).val(t);
    });
});		 
</script>