+ 4
Need help regarding jQuery
actually i was working my code https://code.sololearn.com/W3I8vzwC5p7c/?ref=app and i added an independent close button on the profile section the click function is working there but the profile section is not closing... earlier i was using jquery toggleClass() function that worked fine for me i used "toggleClass('active')" and after adding that close button (not the main close button!... the profile close button...) i used removeClass('active') function on the close button which is not working for me
3 Answers
+ 8
I got a solution
$(".close-profile").click(function(e) {
$('.footer').removeClass('active');
e.stopPropagation();
})
the 'stopPropagation()' works well for me...
as this prevents the clicking of any parent or children elements and clicks only the element specified...
now check the code the close button is working...
https://code.sololearn.com/W3I8vzwC5p7c/?ref=app
+ 11
$('.footer').click(function(e) {
if (e.target !== this)
return;
....
}));
+ 9
Because $('.footer').click() method is executed. It removes the class and then adds it again so it never gets removed.