Which is more efficient please?
var myElement = $(\"#the-name-of-my-element\")
myElement.doSomethingOnce;
myElement.doSomethingTwice;
...
myElement.doSometh
If you are doing multiple tasks with same element than it's better to cache it to variable so JS will not re-select element on every call.
Also it's easier to maintain your code - e.g. if you want to change selector, than you have to change it in one place instead of going through code and searching for it.