jQuery Mouseover Fade Issue
-
Hi,
I have followed and tried to translate a tutorial regarding a jQuery image rollover which I want to use on my post thumbnails. Whilst I get it working from a basic HTML doc, when I try applying it in WordPress I cannot.
Here is the link to the tutorial
I call the jQuery in my Header.php file:
<script type='text/javascript' src='https://iamphiljames.co.uk/test/jquery.js'></script> <script type='text/javascript'> jQuery(document).ready(function(){ jQuery("img.a").hover( function() { jQuery(this).animate({"opacity": "0"}, "slow"); }, function() { jQuery(this).animate({"opacity": "1"}, "slow"); }); }); </script>
Then in my index.php I have two thumbnails:
<div class="pre_post" id="post-<?php the_ID(); ?>"><div class="fadehover"> <?php $postimageurl = get_post_meta($post->ID, 'Thumbnail', true); if ($postimageurl) { ?> <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php echo $postimageurl; ?>" alt="Post Pic" width="239" height="150" class="a"/></a> <?php } ?> <?php $postimageurl = get_post_meta($post->ID, 'Thumbnail1', true); if ($postimageurl) { ?> <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php echo $postimageurl; ?>" alt="Post Pic" width="239" height="150" class="b"/></a> <?php } ?> </div></div>
I have applied the CSS also:
.fadehover { position: relative; } img.a { z-index: 1000; } img.b { position: absolute; left: 0; top: 0; z-index: -10; }
I am unsure what is wrong and whether I have called the jQuery correctly. Can someone please help?
Phil
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘jQuery Mouseover Fade Issue’ is closed to new replies.