Show HN: Tip Calculator – A simple project I made to learn jQuery (codepen.io) 5 points by chickenmonkey 6y ago ↗ HN
[–] codedestroyer 6y ago ↗ to reduce dom transversal you should assign selectors to variables. var tipBtn = $(".tip_btn");then anytime you use tipBtn it has a saved reference to the dom node, if you repeat selectors they recalculate each use. [–] chickenmonkey 6y ago ↗ That's helpful. Thanks!
2 comments
[ 3.4 ms ] story [ 20.4 ms ] threadthen anytime you use tipBtn it has a saved reference to the dom node, if you repeat selectors they recalculate each use.