IE上的jQuery appendTo问题

时间:2011-02-02 16:56:09

标签: jquery

以下代码在Firefox,Safari等上运行良好,完全没有错误。但是不会对任何IE工作,也报告错误。有人可以帮忙吗?

HTML

<p class="tooltip-ent">...</p>

的jQuery

$('<span class="tt-icon-ent">Something</span>').appendTo('.tooltip-ent');
$('<span class="tt-popup-ent">PopupContent</span>').appendTo('.tt-icon-ent');
$('.tt-icon-ent').mouseover(function() { $('.tt-popup-ent', this).addClass('tt-popup-show'); });
$('.tt-icon-ent').mouseout(function() { $('.tt-popup-ent', this).removeClass('tt-popup-show'); });

CSS

for“tt-popup-show”基本上显示块和位置绝对值

2 个答案:

答案 0 :(得分:0)

好的,这适用于我的浏览器:

$(document).ready(function() {
                $('.tooltip-ent').append('<span class="tt-icon-ent"><img src="media/img/icon_ent_small_dark.png" /></span>');

                $('.tt-icon-ent').append('<span class="tt-popup-ent"><span class="link"><a href="#">See all Features</span></span><span class="text">This feature is<br /> available in our<br /> Enterprise Editions.</span>');


                $('.tt-icon-ent').mouseover(function() { $('.tt-popup-ent', this).addClass('tt-popup-show'); });
                $('.tt-icon-ent').mouseout(function() { $('.tt-popup-ent', this).removeClass('tt-popup-show'); });


            });

$('.tt-icon-ent').mouseover(function()位更改为:$('.tt-icon-ent').live('hover', function() {

...并确保$(document).ready()

答案 1 :(得分:0)

顺便说一下:

$('<span/>', {'class': 'tt-icon-ent'})
    .append(
        $('<img/>', {src: 'media/img/icon_ent_small_dark.png'})
    )
    .appendTo('tooltip-ent');