搜索 |
格式化显示从富文本粘贴来的内容
$(function(){
//排除标题中含有"歌"的文章(诗歌按照自己的格式显示,比如居中显示)
//$("#delstyle")为内容包裹层
if($("#delstyle").parent("div.con").children("h1").text().indexOf("歌")==-1){
$("#delstyle").find("p,span,div,samp,strong").each(function(a,b){
$(this).removeAttr('style').removeAttr('class')
// .removeAttr('align')
.css({
"lineHeight":"40px"
})
})
$("#delstyle").find("p,div").each(function(a,b){
// console.log($(this).html())
$(this).html($(this).html()
.replace(/(\s* \s*){1,}|(\r|\n){1,}/ig,"")
.replace(/(\<br\/?\>)/ig,'$1<span style="visibility: hidden;">占位</span>'));
$(this).css({
"textIndent":"2em",
"fontFamily":"宋体",
"textAlign":"justify"
})
})
$("#delstyle").find('img').not('td img').parent('p').css({
"textAlign":"center",
'textIndent':'0em',
// width:"600px",
// height:"auto"
})
};
})