Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 您好,jquery没有';不改变属性值_Javascript_Jquery - Fatal编程技术网

Javascript 您好,jquery没有';不改变属性值

Javascript 您好,jquery没有';不改变属性值,javascript,jquery,Javascript,Jquery,我正在学习web开发,并尝试将jquery用于聊天系统。当我点击提交按钮时,输入的内容将被发送到一个日志文件,我想清除输入字段。我的jquery脚本可以在文件中写入文本,但不会重置输入的属性值。我快疯了,真的不知道该怎么办 下面是html代码 <form name="message" action="#" class="message" method="post"> <input name="usermsg" type="text" id="userms

我正在学习web开发,并尝试将jquery用于聊天系统。当我点击提交按钮时,输入的内容将被发送到一个日志文件,我想清除输入字段。我的jquery脚本可以在文件中写入文本,但不会重置输入的属性值。我快疯了,真的不知道该怎么办

下面是html代码

<form name="message" action="#" class="message" method="post">
            <input name="usermsg" type="text" id="usermsg" size="43%" value="">
            <input name="submitmsg" type="button"  id="submitmsg" value="Send">
</form>

这里是js

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

        $("#submitmsg").click(function(){
            var clientmsg = $("#usermsg").val();
            $.post("update_log.php", {text : clientmsg});
            $("#usermsg").attr("value", "");
            return false;
        });

</script>

$(“#submitsg”)。单击(函数(){
var clientmsg=$(“#usermsg”).val();
$.post(“update_log.php”,{text:clientmsg});
$(“#usermsg”).attr(“value”,“value”);
返回false;
});
这有助于:

$("#usermsg").val('');

您是否尝试过普通的旧
$(“#usermsg”).val(“”)?好的,不客气!