开发者

jQuery hover opacity IE8

This is for a thumbnail - a simple opacity set then hover function.

What am I missing? This is working in most browsers (including IE7) but in IE8 I get nothing.

<script type="text/javascript">
    $(function() {
        // set opacity on page load
        $(".image-thumb").css("opacity", "0.6");
        // on mouse over
        $(".image-thumb").hover(
          function() {
            // animate opacity to full
            $(this).stop().animate({
                opacity: 1
            }, "slow");
          },
          // on mouse out
          function() {
            // animate opacity
            $(this).stop().animate({
          开发者_如何学Python      opacity: 0.6
            }, "slow");
          }
        );
    })
</script>


It seems like you're doing this in a really hard way, at least compared to the way I would do it. Perhaps try this: http://jsfiddle.net/BAJPs/

    $('.image-thumb').bind('mouseover mouseout', function(event) {
        if (event.type == 'mouseover') {
           $(this).stop().animate({
              opacity: 1
           }, "slow");          
        } else {
           $(this).stop().animate({
              opacity: 0.6
              }, "slow");           
        }
    });

UPDATE

I just checked my solution and what you have posted in IE8 and both work!


http://www.w3schools.com/css/css_image_transparency.asp

img
{
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}
img:hover
{
opacity:1.0;
filter:alpha(opacity=100); /* For IE8 and earlier */
}


Use this :

$('.image-thumb').fadeTo('fast',.6);

Hope it helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜