javascript - Removing class from two elements with jQuery -
i have weird (one more time) issue on animation.
in nutshell, have picture, when clicked on it, 2 div appears, , there close button remove divs. when click on button, there 1 div dissapears.
the 2 new divs have got debug class , remove when clicked on button
$('#gallery').on('click', 'li', function(e) { // display animations position var $this = $(this), dataitem = $this.data('item'); // left animation if ( dataitem == 1 ) { console.log( $this ); $this .addclass('active') .find('.info-texte') .removeclass('hidden') .addclass('debug'); // when animation ended add second part $this.find('.debug').on('animationend webkitanimationend oanimationend msanimationend', function() { $this.find('.info-btn') .removeclass('hidden') .addclass('debug'); }); } // supprime le href event e.preventdefault(); }); $('.btn-close').on('click', function() { var $this = $(this); $this .parents() .eq(3) .removeclass('active') .find('.info-texte, .info-btn') .removeclass('debug') .addclass('hidden'); });
you can see in action right here : http://www.jeremybarbet.com/effect/bug.html
as per comments, $this.parents().eq(3)
targeting wrong element
if change $this.parents('li.active')
both of divs should dissapear:
edit
after closer inspection because of click:
$('#gallery').on('click', 'li'
this fired when click on button button inside #gallery li
. have changed code click on image instead open , click on button close:
Comments
Post a Comment