Answer the question
In order to leave comments, you need to log in
Is each needed on click event (simple code inside)?
Elementary question.
Both codes work fine, but which one is better? I don't understand if each is needed?
$('.apply_button, .canget').click(function(e) {
// код
});
$('.apply_button, .canget').each(function(){
$(this).click(function(e) {
// код
}):
}):
Answer the question
In order to leave comments, you need to log in
when clicking each, in any case, it will be superfluous. if the elements on the page were originally - use the first click option. if they are dynamically added to the dom, then use the following construct:
$(document).on('click', '.apply_button, .canget', function(e) {
// код
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question