JS在幻灯片上淡出(不透明) - 在IE中不起作用

时间:2012-10-03 03:38:38

标签: javascript jquery css

我有一个简单的脚本,非常适合FF和Chrome,但IE仍然是一个Partypooper。有什么想法/建议吗?

HTML

<div class="title">
    <p>Change is the law of life.<br />And those who look only to the past or present<br />are certain to miss the future.</p>
</div>

CSS

div.title {
position: fixed;
z-index: 10;
text-align:center;
margin:0 auto;
top: 230px;
width: 100%;
color: #FFFFFF;
}

JS

<script type="text/javascript">  
$(document).ready(function(){
var didScroll = false;
var icon = $(".title");
var $window = $(window);
$(window).scroll(function(){
didScroll = true;
});

window.setInterval(function () {
if (didScroll) {
  if (1-$window.scrollTop()/800 > -10) {
      icon.css({opacity: 1-$window.scrollTop()/800});
  }
  didScroll = false;
}
}, 50);
});
</script>

0 个答案:

没有答案