[英]how can i wrap each of li element with p tag
i have an structure dom : 我有一个结构dom:
<div class="reditor_body">
<p>saeed<p>
<p>aghaebrahimain</p>
</div>
when i was selected the p tag and click the ordered list button , the structure becomes as following : 当我选择了p标签并单击有序列表按钮时,结构如下:
<div class="reditor_body">
<ol>
<li>saeed<li>
<li>aghaebrahimain</li>
</ol>
</div>
my problem is , when i select the each of the li or both and click the ordered list button again , the structure becames: 我的问题是,当我选择li或同时选择li的每一个并再次单击有序列表按钮时,结构变为:
<div class="reditor_body">
saeed
aghaebrahimain
</div>
while i want the following structure : 而我想要以下结构:
<div class="reditor_body">
<p>saeed<p>
<p>aghaebrahimain</p>
</div>
how can i resolved this problem with javascript or jquery like ckeditor or tinymce ? 我该如何使用ckeditor或tinymce之类的javascript或jquery解决此问题?
改变你的jQuery代码记住除去<p>
标记(在情况下,可能是任何其他元件来代替<p>
并删除列表元素换行文本与预先保存的元件(例如,当相同比<p>
标签
First .unwrap()
the ol and use .replaceWith()
in jquery for replace the p tag instead of li 首先
.unwrap()
ol并在jquery中使用.replaceWith()
替换p标签而不是li
$(".reditor_body ol").click(function() {
$(".reditor_body ol li").unwrap("ol").replaceWith(function() {
return $("<p></p>").append($(this).html());
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.