i have an structure 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 :
<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:
<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 ?
改变你的jQuery代码记住除去<p>
标记(在情况下,可能是任何其他元件来代替<p>
并删除列表元素换行文本与预先保存的元件(例如,当相同比<p>
标签
First .unwrap()
the ol and use .replaceWith()
in jquery for replace the p tag instead of li
$(".reditor_body ol").click(function() {
$(".reditor_body ol li").unwrap("ol").replaceWith(function() {
return $("<p></p>").append($(this).html());
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.