这是我的代码有问题的部分,在 .each(function(){ }); 内部运行
$('img','<div>'+ed.selection.getContent({format: 'html'})+'</div>').each(function(){
$img=$('<img/>').attr('src',$(this).attr('src'));
alert($('<p>'+$img+'</p>').html());
if ($(this).attr('height').length>0){
$img.attr('height',$(this).attr('height'));
}
if ($(this).attr('width').length>0){
$img.attr('width',$(this).attr('width'));
}
alert($img.html());
});
首先,我正在处理选定的 html 格式的 tinyMCE 内容,因为 jQuery 可以正确识别它,所以这很好。$img.html() 返回空值,不是未定义,而是空白。测试了 FF 3.6 和 IE8。有人可以解释一下吗?