this question has answer here:
- how empty message in text area jquery? 5 answers
- jquery - remove user input text textarea 5 answers
i have comment box (textarea) inside dialog. if comment saved want clear contents of textarea , close dialog box. atm dialog box close need wipe contents.
<textarea id="commentbox" type="text" runat="server" rows="7" maxlength="2000" /> if (commentsuccessfullyupdated == "true") { //empty comment box?? //something $("#commentbox").empty(); //closes dialog box $("#dialog").dialog('close');
thanks replies
edit: guys. running through code not working. think has in order pick correct vales , resolve biding issue had use:
function submitbutton() { var commentboxdata = $('#<%=commentbox.clientid%>').val(); }
when run through breakpoint returns:
function submitbutton() { var commentboxdata = $('#ctl00_contentplaceholder1_commentbox').val(); }
and:
<textarea name="ctl00$contentplaceholder1$commentbox" id="ctl00_contentplaceholder1_commentbox" type="text" rows="7" maxlength="2000"> </textarea>
so im guessing im not referencing same textarea when try empty it. tried
$("#commentbox.clientid").val('');
but no joy....ay ideas?
$('#commentbox').val('');
use val()
method, passing in empty string.
documentation: http://api.jquery.com/val
also, mark wrong. textarea
isn't self-closing element. need </textarea>
tag. , type="text"
isn't necessary (probably not valid either)
as per edit, can either set ids static @ top of .aspx file (i think it's clientid="static"
)
or can use different selector:
$('textarea').filter('[id*=commentbox]').val('');
Comments
Post a Comment