尝试使用Jquery设置字段-无效

尝试使用Jquery设置字段-无效,jquery,Jquery,我好像没法让它工作。我正在使用JQuery,这是我的一个新习惯。 警报消息是--->在…函数(a){return J。。。。。。 而且脚本不起作用 <!DOCTYPE html> <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script

我好像没法让它工作。我正在使用JQuery,这是我的一个新习惯。 警报消息是--->在…函数(a){return J。。。。。。 而且脚本不起作用

<!DOCTYPE html>
<html>    
<head>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

    <script type="text/javascript">

        $(document).ready(function() 
        {                
            $("input").click(function()
            {

                alert('before...' + $(this).text);

                if ($(this).text == "Search  ")
                {
                   $(this).val("You have set me to value.");   
                   $(this).css({"style.color":"#000000"});
                   $(this).css({"fontStyle":"italic"});  
                }
                else
                {
                   $(this).val("");                      
                }

                alert('after...' + $(this).text);                    

           });          
        });

    </script>

    <title>My page</title>

</head>

<body>
   <div class="historysearch">
      <input id="textinput" type="text" value="Search  "/>                              
   </div> 
</body>

$(文档).ready(函数()
{                
$(“输入”)。单击(函数()
{
警报('before…'+$(this).text);
if($(this).text==“搜索”)
{
$(this.val(“您已将我设置为value”);
$(this.css({“style.color”:“#000000”});
$(this.css({“fontStyle”:“italic”});
}
其他的
{
$(此).val(“”);
}
警报('after…'+$(this).text);
});          
});
我的页面

使用
val()
方法获取输入值而不是
。text

工作演示
$(文档).ready(函数(){
$(“输入”)。单击(函数(){
警报('before…'+$(this.val());
if($(this.val()=“搜索”){
$(this.val(“您已将我设置为value”);
$(this.css)({
“style.color”:“#000000”
});
$(this.css)({
“字体样式”:“斜体”
});
}否则{
$(此).val(“”);
}
警报('after…'+$(this.val());
});
});

使用
val()
方法获取输入值而不是
。text

工作演示
$(文档).ready(函数(){
$(“输入”)。单击(函数(){
警报('before…'+$(this.val());
if($(this.val()=“搜索”){
$(this.val(“您已将我设置为value”);
$(this.css)({
“style.color”:“#000000”
});
$(this.css)({
“字体样式”:“斜体”
});
}否则{
$(此).val(“”);
}
警报('after…'+$(this.val());
});
});