开发者

Extract part of pasting html in CKEditor

I am using CKEditor for my asp.net mvc (C#) application.

I need to extract a part of html before pasting to the CKEditor.

For Ex, i have the following html ready to be pasted to开发者_如何转开发 CKEditor:

<html>
<body>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                Dummy Content
            </td>
        </tr>
        <tr>
            <td>
                <table width="100%" border="0" id="tabletocopy" cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            Actual Content
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>

I need to copy only the html of the table "tabletocopy", not the entire(including body) html, something like:

<table width="100%" border="0" id="tabletocopy" cellpadding="0" cellspacing="0">
   <tr>
      <td>
         Actual Content
      </td>
   </tr>
</table>

I found the paste event of CKEditor, but i am not sure on how to use this for my need.

Any ideas on this?


On paste event, you will get the html in e.data.html as described in link.

In that event you can extract the html using jquery.

e.data.html = $(e.data.html).find("#tabletocopy").html();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜