Fade between images with jQuery
-
Hi,
I’m trying to apply a fade effect between a color image and a b&w image, as explained here , and also discussed in this thread , but what I get is one picture showing in the top left corner and the other in the right one, with no effect.
Tried with a few different themes.My header.php code:
<?php wp_enqueue_script("jquery"); ?> <?php wp_head();?> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/fader.js"></script> <div class="fadehover"> <img src="https://localhost/nextGen/wp-content/themes/twentyten/images/cbavota.jpg" alt="" class="a" /> <img src="https://localhost/nextGen/wp-content/themes/twentyten/images/cbavota-bw.jpg" alt="" class="b" /> </div>
style.css code:
.fadehover { position: relative; } img.a { z-index: 1000; } img.b { position: absolute; left: 0; top: 0; z-index: -10; }
I wasn’t sure where to put it so tried a few places without any success. Now it’s placed after the header and right before “#content {“.
jQuery script code:
<script type='text/javascript'> jQuery(document).ready(function(){ jQuery("img.a").hover( function() { jQuery(this).stop().animate({"opacity": "0"}, "slow"); }, function() { jQuery(this).stop().animate({"opacity": "1"}, "slow"); }); }); </script>
Would appreciate any kind of help.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Fade between images with jQuery’ is closed to new replies.