javascript - JQuery 1 Click fires 2 conditions (if) -
$('.anfahrt').click(function() { $button = $(this); if ( clickedc == 0){ if( !$button.hasclass( 'disabled' ) ) { $button.addclass( 'disabled' ); clickedc = 1 $('.lupe').animate({opacity: '0'},750) $('.card > img').animate({height: 150, width: 193, opacity: '1', left: 0, top: 9},500) $('.contact-content2').animate({opacity:'1'},500).animate({opacity: '0'},500) $('.cardgreen > img').animate({height:150, width: 193, opacity: '0'},500).animate({opacity: '1', top: 9},500, function() { $button.removeclass('disabled') } ); } } }); $(document).(click(function() { $button = $(this); if ( clickedc == 1){ if( !$button.hasclass( 'disabled' ) ) { $button.addclass( 'disabled' ); clickedc = 0 $('.cardgreen > img').animate({opacity: '0'},300).animate({height:0,width:0}); $('.contact-content2').show(0).animate({opacity: '1'},300) $('.clickding').animate({width: '0', height: '0'},0) $('.card > img').animate({opacity: '1'},300) .animate({opacity: '0', width: 0, height: 0, left:194, top:75},270, function() { $button.removeclass('disabled') } ); } } }));
so click on div.. , animation start (fadein). should stop... user clicks everywhere on document , 2nd animation (fadeout) should start. - not work .. cause when click div fadein animation starts after 2nd animation starts right away. theres no stop.. pls me how fix this.
the reason click event bubbling document level when click div
.
what want use stoppropagation method on event:
$("#yourdiv").click(function(event){ alert("your div clicked"); event.stoppropagation(); });
Comments
Post a Comment