I have a page with multiple comment boxes. When someone clicks the submit button for the comment box JQuery handles the submission and posts the comment. I then want to set the text in the comment box back to empty. I’m using something like this:
$('.formstyle').submit(function() {
$.post("/messages/", $(this).serialize());
return false;
});
I know there is the .reset() option but that still doesn’t tell me how to access a single text element among many. I can use $(":input[name=new_message]").val(''); to set the text of all the text boxes on the page but that could be annoying if someone has an message they haven’t submitted. I would think something along the lines of this.(":input[name=new_message]").val(''); would work but no dice. I think I’m just not connecting the dots between this (or more likely $(this)) and the input selector.
You can simply use this:-