-1

I'm learning web development and I try to use jquery for a chat system. When i click to the submit button the content of input will be sent to a log file and I want clear that imput field. My jquery script works in writing the text on the file but doesn't reset the attribute value of the input. I'm getting crazy and I really don't have any idea what to do

Here is the html code

<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>

Here the 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>

1 Answers1

1

This can help:

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