CKEditor - 使用 jquery val() 获取 HTML 值

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

我看到很多答案都说要使用以下方式获取 CKEditor 内容:

CKEDITOR.instances['editor1'].getData();

但是我们一直在使用以下似乎有效的方法:

$("#editor1").val()

两者有区别吗?

jquery ckeditor
1个回答
0
投票

这要看情况。如果您使用提供 jQuery 集成的 jQuery Adapter,则

CKEDITOR.instances['editor1'].getData()
$("#editor1").val()
可以互换使用,但如果您不使用 jQuery Adapter,则需要使用
CKEDITOR.instances['editor1'].getData()
,因为
$("#editor1").val()
不会返回更改的内容。

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