开发者

Problem with setting opacity by jQuery in IE7 and IE8

开发者 https://www.devze.com 2023-03-07 17:22 出处:网络
I have this code: <ul id=\'menu\'> <li class=\"no1\"> </li> <li class=\"no2\"> </li>

I have this code:

<ul id='menu'>
  <li class="no1"> </li>
  <li class="no2"> </li>
  <li class="no3"> </li>
</ul>

Classes no1 - no3 just set background images for "li" tags. I use following code to set opacity of all li elements to 0.15 :

$('#menu > li').hover(function () {
      $('#menu > li')开发者_如何学C.stop().animate({'opacity':'0.15'},"slow");
}

Everything is OK in Opera,Chrome,Safari and Firefox, but it doesnt work in IE7 and IE8 (and even maybe IE9)

I discovered I have to use style.filter property in IE but don't know how to exactly implement it in the code above. Any idea ?


The opacity css type does not exist in those versions of IE,

so do: 'filter': 'alpha(opacity=15)' for IE

Read up on opacity here


css is filter:alpha(opacity=15); Not sure how the jquery syntax for assigning it will go though I guess:

 $('#menu > li').stop().animate({'opacity':'0.15'; 'filter':'alpha(opacity=15)'},"slow");

Not entirely sure though.


Try:

$('#menu > li').stop().fadeTo("slow", 0.15);
0

精彩评论

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