$("body *").live('mouseover', function() {
var currentId = $(this).attr('id');
var html = "<div id='perfect4' style='font-size:10px;'><div id='pos1'><br>ID: " +currentId+
" <br>Klasse: " +currentClass+ " </div><div id='pos' style='width:300px'></div></div>";
$("#perfect4").html(html).replacewith(html);
});
在ff中有效,因为有错误(replacewith
)
我知道,replaceWith
是正确的
但没有这个,它就行不通了
不起作用:
$("#perfect4").html(html)
为什么?
答案 0 :(得分:0)
你不应该在元素中插入html,而只是做
$("body *").live('mouseover', function() {
var currentId = $(this).attr('id');
var html = "<div id='perfect4' style='font-size:10px;'><div id='pos1'><br>ID: " +currentId+
" <br>Klasse: " +currentClass+ " </div><div id='pos' style='width:300px'></div></div>";
$("#perfect4").replacewith(html); // without the .html() call
});
(假设您已经开始使用'#perfect4'
元素)