empty textarea using jquery 1

empty textarea using jquery

$('#message').val('');

Here is what the above code is Doing:
1. We’re creating a function called send_message.
2. We’re creating a variable called message that is equal to the value of the textarea with the id of message.
3. We’re creating a variable called chatroom that is equal to the value of the input with the id of chatroom.
4. We’re creating a variable called csrfmiddlewaretoken that is equal to the value of the input with the id of csrfmiddlewaretoken.
5. We’re creating a variable called url that is equal to the value of the input with the id of url.
6. We’re creating a variable called data that is equal to a JavaScript object with the keys message, chatroom, and csrfmiddlewaretoken.
7. We’re using jQuery’s ajax method to send a POST request to the url we defined in step 6.
8. We’re using jQuery’s val method to set the value of the textarea with the id of message to an empty string.

Similar Posts