CKEditor、Jquery - 查找和替换 HTML
我对 CKEditor 完全陌生,因此请忍受我的愚蠢问题。我有一个 CMS,它使用 CKEditor 将文章输入数据库。我被要求为编辑器编写一个插件来执行特定任务,如下所示:
我在编辑器中有一个图像。当我单击图像以选择它并单击我编码的按钮时,它会为我提供图像 html,如 。现在我需要查明图像标签是否用另外的 html 包装,例如:
<div class="photo">
<p class="inner">
<img src="imageurl" border="0" /><span>some text here</span>
</p>
</div>
如果是,我需要能够编辑 span 标签中的文本,并能够向 DIV 或 P 添加内联样式,如果不是,我需要换行 :
<div class="photo">
<p class="inner">
<img src="imageurl" border="0" /><span>some text here</span>
</p>
</div>
PS 我可以坐下来,如果有时间的话可能会想出一个解决方案。但我的截止日期太近了!
有人可以帮我解决这个问题吗?非常感谢您的帮助。
谢谢, 右
I am totally new to CKEditor, hence please bear with my stupid questions. I have a CMS that uses CKEditor to enter articles into a DB. I have been asked to write a plugin to the editor to do a particular task which is as follows:
I have an image in the editor. When I click on the image to select it and click on a button that I coded it gets me the image html like <img src="imageurl" border="0" />. Now I need to find out if the image tag is wrapped with furthermore html like:
<div class="photo">
<p class="inner">
<img src="imageurl" border="0" /><span>some text here</span>
</p>
</div>
if yes, I need to be able to edit the text in the span tag and be able to add inline style to DIV or P, if not I need to wrap <img src="imageurl" border="0" /> with :
<div class="photo">
<p class="inner">
<img src="imageurl" border="0" /><span>some text here</span>
</p>
</div>
P.S. I can sit thru and may be come up with a solution if I has sometime. But my deadline is too close!
Could someone please please help me with this? Your help is much appreciated.
Thanks,
R
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你可以使用 Jquery 函数
parent()
来获取“ html 结构中从开始的更高级别”
I think you can use the Jquery function
parent()
to get the "higher levels" in your html structure starting from<img />