开发者

Why doesn't this fadeOut() work in Internet Explorer?

开发者 https://www.devze.com 2023-03-28 02:53 出处:网络
Tested on IE7, IE8, IE9... and the fadeOut() is not applied : <table> <tr class=\"sideOn hidden\">

Tested on IE7, IE8, IE9... and the fadeOut() is not applied :

<table>
    <tr class="sideOn hidden">
        <td class="trackBotton">
            <input type="submit" value="Remove" onClick="remSide(this);return false" />
        </td>        
    </tr>
</table>

function remSide(param) {
    开发者_C百科$(param).parents('.sideOn').fadeOut(500, function() {
           $(this).remove();
    });
}

Why is this and how can I fix this problem?

Also removing the remove() doesn't work:

function remSide(param) {
    $(param).parents('.sideOn').fadeOut(500);
}


JQuery uses filters to do the fading in Internet Explorer, and filters only apply to elements that has layout.

You can give the table row layout like this:

.sideOn { position: absolute; }

Then the elements fade in Internet Explorer, but changing the position style of a table row is not recommended, so you should use some other element for what you want to fade.


Guffa had it right with his answer - so I'd like to offer an alternative (workaround for IE, that is):

function remSide(param) {
    $(param).parents('.sideOn').find('td').fadeOut(500, function() {
           $(this).parent().remove();
    });
}

This fades out all the <td>s, then removes the <tr> itself. Seems to work fine in IE8.

Demo: http://jsfiddle.net/B7ndq/3/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号