我正在使用ckeditor;目前还有一个错误,使编辑器用<span>
(I made a post on it here)替换<font>
标签。我提交了一个错误报告来解释这个问题,但不能等待修复,所以现在我想实现自己的。我想知道什么是将<font>
标签无缝转换为<span>
标签的可靠方法。例如,如果我有以下内容:
<font face="Raleway" size="18" color="blue" class="makers styles">Simple Text</font>
跨度相当于:
<span style="font-family:Raleway; size:18px; color:blue;" class="makers styles">Simple Text</span>
答案 0 :(得分:1)
这样的事情应该有效:
$(function() {
// Your WYSIWYG content string
var content = "";
$('font', content).each(function() {
// Append a new <span> after this <font>
$(this).after(function() {
var span = $('<span>').text($(this).text());
if(this.hasAttribute('face')) {
span.css('font-family', $(this).attr('face'));
}
if(this.hasAttribute('size')) {
span.css('font-size', $(this).attr('size') + 'px');
}
if(this.hasAttribute('color')) {
span.css('color', $(this).attr('color'));
}
if(this.hasAttribute('class')) {
span.attr('class', $(this).attr('class'));
}
return span;
});
// Remove this <font>
$(this).remove();
});
});