Just curious if there is an established “best practice” for target children within the parent.
For example, if I want to create a click event for children of a parent element, which one is preferable?
a) specify the parent element and id and do:
$('ul#parent li').click(function() {});
b) or, instead, give each of the children a class name and configure them directly:
$('li.child').click(function() {});
I ask, because I'm trying to squeeze every bit of performance, I can get a somewhat large application. The logic would determine that identifier targeting is faster than class name targeting, but the parent> child structure negates this advantage and justifies targeting with the class name instead?
Thank you for understanding.
source
share