Using jQuery button hover effect
-
I’m trying to get a button working so that the image changes on mouse-over. Here is the page:
https://2013.whitehallrow.com/?page_id=286It’s the “See the full photo album” button. I downloaded jQuery and then uploaded it into wp-admin/js. Here is the code for loading jQuery in header.php (I added the two lines before and after wp_head):
<?php wp_enqueue_script(“jquery”); ?>
<?php wp_head(); ?>
<script type=”text/javascript” src=”<?php bloginfo(“template_url”); ?>/js/jquery-1.9.1.min.js”></script>And then here is the code for trying to get the button to work on the page:
<script type=’text/javascript’>
$(document).ready(function(){
$(“.modelbutton”).hover(function() {
$(this).attr(“https://2013.whitehallrow.com/wp-content/uploads/2013/05/”,”buttonA_on.png”);
}, function() {
$(this).attr(“https://2013.whitehallrow.com/wp-content/uploads/2013/05/”,”buttonA_off.png”);
});
});
</script><img src=”https://2013.whitehallrow.com/wp-content/uploads/2013/05/buttonA_off.png” alt=”See the full photo album” class=”modelbutton” />
My JS skills are pretty terrible, so I know there could be a number of things that I’m doing wrong… could I get some guidance on how this is done right?
- The topic ‘Using jQuery button hover effect’ is closed to new replies.