To listen events on elements, I think to listen on document level:
$(document).on(\'click\', \'.myclass\', function() {/*do something*/});
If .myclass
is added dynamically in your document, this is what you prefer
$(document).on('click', '.myclass', function() {/*do something*/});
To make it more efficient, consider this - (As you would like to use the first style extensively)
// <-- added dynamically
You can do this -
$('.parentClass').on('click', '.myclass', function() {/*do something*/});
See Api Docs - http://api.jquery.com/on/