Reputation: 145
I'm using the code below, the .click action works fine on its own, as soon as I add .hover, then .hover works and .click stops working. Any idea why this happens and how to fix it?
$('#11').click(function(){
$('#widget').load('../212/?id=11');
$(this).attr("src", "<?php bloginfo('stylesheet_directory'); ?>/images/category-fantasy-32-disable.png");
});
$('#11').hover(
function () {
//hover event
$(this).attr("src", "<?php bloginfo('stylesheet_directory'); ?>/images/category-fantasy-32-disable.png");
},
function () {
//hover out event
$(this).attr("src", "<?php bloginfo('stylesheet_directory'); ?>/images/category-fantasy-32.png");
});
Upvotes: 0
Views: 69
Reputation: 1019
The solution is to bind to click and hover both. Here is a sample code
$('p').on('click hover', function () {
alert("Clicked");
});
$('p').hover(
function(){
console.log("X");
},
function(){
console.log("Y");
}
);
This will trigger both hover in and hover out method. and if you click it works as well. Working link: http://jsfiddle.net/43BW4/
Upvotes: 1