Tuesday 15 January 2013

change Jquery hover addclass to click addclass -



change Jquery hover addclass to click addclass -

i have problem alter addclass hover click:

this code:

$('.showcase-panels-container > ul > li').hover ( function() { $(this).parents('.showcase-panels-container').attr('data-hover', $(this).index()); $(this).addclass('hovered'); var $this = $(this); $(this).siblings().each(function() { if ($(this).index() < $this.index()) { $(this).addclass('right-was-hovered'); } else if ($(this).index() > $this.index()) { $(this).addclass('left-was-hovered'); } }); }, function() { $(this).parents('.showcase-panels-container').removeattr('data-hover') .find('> ul > li').removeclass('hovered right-was-hovered left-was-hovered'); } );

and u can check on: http://jsfiddle.net/6vvk4ct8/

i tried alter code next illustration of on this: http://jsfiddle.net/xbfmv/

try this:

jquery(document).ready(function($) { $('.showcase-panels-container > ul > li').click(function() { $(this).parents('.showcase-panels-container').removeattr('data-hover').find('> ul > li').removeclass('hovered right-was-hovered left-was-hovered'); $(this).parents('.showcase-panels-container').attr('data-hover', $(this).index()); $(this).addclass('hovered'); var $this = $(this); $(this).siblings().each(function() { if ($(this).index() < $this.index()) { $(this).addclass('right-was-hovered'); } else if ($(this).index() > $this.index()) { $(this).addclass('left-was-hovered'); } }); } ); }); working fiddle: http://jsfiddle.net/robertrozas/6vvk4ct8/3/

jquery hover click addclass

No comments:

Post a Comment