gpt4 book ai didi

javascript - ckeditor insertHtml() 形式 jquery.load

转载 作者:行者123 更新时间:2023-12-03 11:16:23 25 4
gpt4 key购买 nike

<script type="text/javascript">
$( "#x_img" ).load( "../x_img.php?id=123" );


$("#x_img").delegate("img", "click",function() {
CKEDITOR.instances.editor1.insertHtml('<img src="'+$(this).attr('alt')+'" />');
});
</script>

我有一个加载图像(x_img)供用户使用的函数。 x_img jq.load 在此页面中。

使用此代码,我单击要插入的图像,效果很好。但是,我无法获取图像 src值(value)!

CKEditor 显示:<img src="undefined" />

问题是图像在另一个页面上吗?

最佳答案

如果您的编辑器正在显示

<img src="undefined" />

然后

$(this).attr('alt')

将返回undefined因为img节点没有alt='something'属性。这个undefined然后被连接到您的 imgsrc属性。

尝试将图像标记更改为如下所示:

<img alt="/images/funtimesatthebeach.jpg" />

然后,您的代码应该加载 /images/funtimesatthebeach.jpg 处的图像。 .

关于javascript - ckeditor insertHtml() 形式 jquery.load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27323958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com