使用数据ID复制TinyMCE的内容

问题描述 投票:0回答:2

我有TinyMCE的Wordpress UserFrontend Pro实现,其中html是:

<body id="tinymce" class="mce-content-body post_content_442 post-type-page post-status-publish page-template-default locale-en-us mceContentBody webkit wp-editor html5-captions" data-id="post_content_442" contenteditable="true"><p>The text that I want to copy</p></body>

我正在尝试复制内容,即:

<p>The text that I want to copy</p>

在这种情况下。

我尝试使用

$('[data-id="post_content_442"]')

但是这会打印出整个HTML本身。

我如何仅打印具有html格式的输入文本?谢谢。

javascript jquery wordpress tinymce
2个回答
0
投票

$('[data-id =“ post_content_442”] p')。text();


0
投票

问题是输入位于ID为post_content_442_ifr的iframe中。所以

$jq2("#post_content_442_ifr").contents().find("#tinymce").html();

允许我选择所需的文本。

谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.