I had a textarea box on a web form and was using some jquery code to set values and it was working great. I changed the control to be a richtextbox .. well it renders it as such at least, and now the code can't find the control with jquery. Why?
rendered markup:
</td></tr><tr><td width="190px" valign="top" class="ms-formlabel"><H3 class="ms-standardheader"><nobr>BodyText</nobr></H3></td><td width="400px" valign="top" class="ms-formbody"><span dir="none">
<span dir="ltr">
<textarea name="ctl00$PlaceHolderMain$g_d63cd1e2_dcca_4553_8a0c_df6047a0a489$ff5_1$ctl00$ctl00$TextField" rows="6" cols="20" id="ctl00_PlaceHolderMain_g_d63cd1e2_dcca_4553_8a0c_df6047a0a489_ff5_1_ctl00_ctl00_TextField" title="BodyText" class="ms-long" dir="none"></textarea>
<input name="ctl00$PlaceHolderMain$g_d63cd1e2_dcca_4553_8a0c_df6047a0a489$ff5_1$ctl00$ctl00$TextField_spSave" type="HIDDEN" id="ctl00_PlaceHolderMain_g_d63cd1e2_dcca_4553_8a0c_df6047a0a489_ff5_1_ctl00_ctl00_TextField_spSave" />
if (browseris.ie5up && browseris.win32 && !IsAccessibilityFeatureEnabled()){RTE_ConvertTextAreaToRichEdit("ctl00_PlaceHolderMain_g_d63cd1e2_dcca_4553_8a0c_df6047a0a489_ff5_1_ctl00_ctl00_TextField", true, false, "", "1033", null, null, null, null, null,"Compatible", "\u002fucharterror",null,null,null,null);}else{document.write(" Click for help about adding basic HTML formatting. ");};
Here's the code I was using:
$('textarea[title$=BodyText]').val('hello');
Not开发者_开发问答 sure if it matters, but it's being generated by SharePoint asp.net
Put BodyText
in quotes:
$('textarea[title$="BodyText"]').val('hello');
You need quotes around BodyText.
$('textarea[title$="BodyText"]').val('hello');
精彩评论