多行富文本字段上的Jquery选择器

多行富文本字段上的Jquery选择器,jquery,html,sharepoint,Jquery,Html,Sharepoint,我在我的sharepoint NewForm页面上添加了以下HTML,以创建一个临时多行富文本字段 <div class="ms-inputBox ms-inputBoxActive" id="NewLog2" title="NewLog3"> <div id="NewLog5" title="NewLog" name="NewLog5" role="textbox" style="overflow: auto; min-height: 168px; max-heigh

我在我的sharepoint NewForm页面上添加了以下HTML,以创建一个临时多行富文本字段

<div class="ms-inputBox ms-inputBoxActive" id="NewLog2" title="NewLog3">
    <div id="NewLog5" title="NewLog" name="NewLog5" role="textbox" style="overflow: auto; min-height: 168px; max-height: 336px;" contenteditable="true" aria-autocomplete="both" aria-multiline="true" RteDirty="false">
    </div>
</div>

选择器错误还是html错误?

让我们假设您希望通过单击按钮来读取富文本,因此您可以尝试以下方法:

$('#btn').click(function() {
   alert($('#NewLog5').html());
});

谢谢你的提示!以下两种方法都有效

var x = $('#NewLog').html();alert(x);
var x = $('#NewLog').text();alert(x);
与HTML一起工作

<div class="ms-inputBox ms-inputBoxActive">
    <div id="NewLog" role="textbox" style="overflow: auto; min-height: 168px; max-height: 336px;" contenteditable="true" aria-autocomplete="both" aria-multiline="true" RteDirty="false">
    </div>
</div>


不确定上一个建议的测试为什么不起作用。

在哪里输入值?这应该在输入或按键事件中,实际上是在预存储操作中。javascript读取屏幕元素并在保存之前对其进行处理。我在代码中添加了:var x=$('#NewLog5').html();警报(x);警报返回时显示“undefined”(未定义),我还没有完全在Sharepoint上工作,但是您可以右键单击表单>打开检查器>检查div,看看文本是否存在吗?如果是,也许你可以在控制台中运行这个选择器,看看它给出了什么操作。
<div class="ms-inputBox ms-inputBoxActive">
    <div id="NewLog" role="textbox" style="overflow: auto; min-height: 168px; max-height: 336px;" contenteditable="true" aria-autocomplete="both" aria-multiline="true" RteDirty="false">
    </div>
</div>