Whether written in JS (jQuery)?

There is such code https://jsfiddle.net/beLsd91g/

The logic now works properly and does the following:

if we select any element in the column, the next column becomes active, etc. but if you change the selection in the previous column to the next column, the flies of choice, and the column behind the next becomes inactive.

Question: is it true I all realized by means of jQuery or you can be different and less resource-intensive for the browser?
August 23rd 19 at 10:39
3 answers
August 23rd 19 at 10:41

1) It is in principle not a bug, but instead of a method .click() is better to use .on(). This way you will have uniformity in the code.
2) $(this) to be stored in a variable, not to create each time an instance of jQuery
3) $(this).closest('.col') also be saved to a variable, because the search in the DOM tree, the most costly operation in scripts.
4) Use a chain of calls in full, and not partially as it is now.
5) Some extra code you have written, I don't know what it's for.

In the end your code will look like this: https://jsfiddle.net/beLsd91g/1/
Thank you very much for the answer! I will try to think globally! Unnecessary code You're talking about nextAll? It is necessary that at a clique on an element in the first column, I have removed all the active elements in the other columns and 3 and 4 column became disabled. - Darrin commented on August 23rd 19 at 10:44
August 23rd 19 at 10:43
If you're happy what's the problem? And what makes you think that it is expensive for the browser?) On small projects you'll never hit the ceiling of performance.
But if it is an online store attendance had from 100 thousand a day? The client requires from us the highest possible performance, and I JS recently mastered, so decided to ask. Thanks for the reply. - Darrin commented on August 23rd 19 at 10:46
: with a large attendance only makes sense to improve the performance of the backend. On the client side, it begins to play the role, then when the site becomes large and complicated application. - Darrin commented on August 23rd 19 at 10:49
August 23rd 19 at 10:45
All right.
Thanks for the reply. - Darrin commented on August 23rd 19 at 10:48

Find more questions by tags CSSHTMLJavaScriptjQuery