jquery找不到richtextbox?
我在 Web 表单上有一个文本区域框,并使用一些 jquery 代码来设置值,并且效果很好。我将控件更改为 Richtextbox ..它至少将其呈现为这样,现在代码无法使用 jquery 找到该控件。为什么?
渲染标记:
</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.
");};
这是我使用的代码:
$('textarea[title$=BodyText]').val('hello');
不确定它是否重要,但它是由 SharePoint asp.net 生成的
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
BodyText
放在引号中:Put
BodyText
in quotes:您需要在 BodyText 周围加上引号。
You need quotes around BodyText.