jQuery fade effects in IE(8)

Sample code:

<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
span {display:none;}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("span").fadeIn(3000);
  });
});
</script>
</head>
<body>
<button>Fade in</button>
<span>This is some text.</span>
</body>
</html>

It doesn’t work in IE8 and probably older versions. Any solution?

Hi there,

Change the span to a div and it will work.

<!DOCTYPE html>
  <html>
    <head>
    <title>Strange IE8</title>
    <style>
      div {display:none;}
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script>
      $(document).ready(function(){
        $("button").click(function(){
          $("div").fadeIn(3000);
        });
      });
    </script>
  </head>
  <body>
    <button>Fade in</button>
    <div>This is some text.</div>
  </body>
</html>

BTW, using a span did work in older IE versions. It is just IE8 being weird!

Thanks for the answer! :slight_smile: