Created
January 26, 2016 21:20
-
-
Save joshdcomp/d65dad009d21dcee2620 to your computer and use it in GitHub Desktop.
When writing event handlers, manipulate elements relative to the element was clicked to avoid unintended concequences.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('._ak-subscribe-close').on('click', function(){ | |
$('._ak-email_subscribe').removeClass('_ak-email_subscribe--opened'); | |
}); | |
//becomes | |
$('._ak-subscribe-close').on('click', function(e){ | |
var $wrapper = $(e.currentTarget).closest('._ak-email_subscribe') | |
$wrapper.removeClass('_ak-email_subscribe--opened'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment