[英]Get html of a table in TinyMCE (using the table plugin)
我有一個加載了表格插件的 TinyMCE 編輯器(我正在使用 TinyMCE 高級 Wordpress 插件)。 我必須得到一個選定表的 HTML 代碼(您當前正在編輯的表 - 您打開了調整大小控件)。 對於普通文本,我可以使用tinyMCE.activeEditor.selection.getContent()
,但這在處理表格時不起作用。 這樣做的正確方法是什么?
謝謝。
您可以使用tinyMCE.activeEditor.selection.getNode();
. 如果這是一個表格元素,你得到了你的表格,並且能夠使用 html
var node = tinyMCE.activeEditor.selection.getNode();
var html = node.innerHTML;
// now you will only need to take care of the surrounding table element
// something like "<table>"+ html +"</table>"; maybe having a look at node.attributes
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.