jquery png fix on hidden div and jquerybrowser question

Posted by Jared on Stack Overflow See other posts from Stack Overflow or by Jared
Published on 2009-12-11T21:07:06Z Indexed on 2010/06/10 4:52 UTC
Read the original article Hit count: 353

Filed under:
|
|

Hello,

I have some code that if Javascript is available, it will remove a GIF image and replace it with a PNG image. The PNG is display:none and the GIF is visible.

Since IE6- browsers can't load PNG, I have loaded the jquery PNG fix. But it only seems to work if the image is already visible.

The other issue is I am trying to get the jquery.browser function to apply to less than version 6, and I am not having much luck.

<script type="text/javascript">
    $(document).ready(function(){
    	$("#gif").hide();



    	jQuery.each(jQuery.browser, function(i, val) {
  if($.browser.msie && jQuery.browser.version <="6"){
     $("#png").show(); 
     $('.png').pngFix()
  }else{
     $("#png").fadeIn("slow");

  }
});





    });

</script>

HTML

<img class="png" id="png" src="images/main_elements/one-2-flush-it-campus-challenge.png" style="display:none;" />
<img id="gif" src="images/main_elements/one-2-flush-it-campus-challenge.gif"/>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about browser