基本上HTML元素包含一个body标记。在这个body标签中,我们添加了所需的html内容。在我的例子中,HTML文件有两个主体内容,一个用于整个HTML内容,另一个用于富文本编辑器。我需要使用第二个正文获取富文本编辑器文本。
我已经试过了
get body tag value from website
Get all elements in the body tag using pure javascript
第二个正文html内容如下,
<body marginwidth="0" marginheight="0" spellcheck="true" class="wysihtml5-editor" style="font-variant-ligatures: normal; font-variant-caps: normal; background-color: rgb(255, 255, 255); color: rgb(95, 100, 104); cursor: auto; font-family: "Open Sans", sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 18px; letter-spacing: normal; text-align: start; text-decoration: none solid rgb(95, 100, 104); text-indent: 0px; text-rendering: auto; word-break: normal; word-wrap: break-word; word-spacing: 0px;" contenteditable="true">testing</body>
我还尝试使用类名,如下所示,但显示了$(…)。文本不是函数。
$(".wysihtml5-editor").text()
谢谢