在 Textbox 中输入一行字,怎样实现当鼠标点击Textbox时,这里面的字消失

解决方案 »

  1.   

    失去焦点的客户端事件是   onblur
      

  2.   

    用JS实现
    JQuery实现
    $("#textBox1").click(function(){
    $(this).text("");
    })
      

  3.   

    <asp:TextBox id="o" value="请输入搜索关键字" />document.onkeydown=function(){
               if(event.keyCode=="13")
               {    var user = '';
                    if (user=="")
                    {
                        if (document.getElementById("o").value=="请输入搜索关键字")
                        {
                        document.getElementById("Button2").click();         
                        return false;
                        }else
                        {
                       document.getElementById("btnQSearch").click();
                        return false;
                        }
                    }else
                    {
                         if (document.getElementById("o").value=="请输入搜索关键字"||document.getElementById("o").value=="")
                        {
                            alert("请输入搜索关键字");
                            return false;
                        }
                    }
                   }
                }
                
      

  4.   

    onclick  onfocus  都可以
      

  5.   

     <asp:TextBox ID="TextBox1" runat="server" value="想找什么?输入名称试试" onfocus="if(value=='想找什么?输入名称试试'){value=''}"  onblur="if(value==''){value='想找什么?输入名称试试'}"  ></asp:TextBox>
      

  6.   


    onfocus="if (this.value=='请输入') this.value=''" onblur="if(this.value=='') this.value='请输入'"