Which is more efficient please?
var myElement = $(\"#the-name-of-my-element\")
myElement.doSomethingOnce;
myElement.doSomethingTwice;
...
myElement.doSometh
jQuery does not cache selectors - as detailed in this question:
Does jQuery do any kind of caching of "selectors"?
As a result, each time you perform $("#the-name-of-my-element")
jQuery is performing some work to match the selector.
For anything other than trivial code, I'd always cache selectors.
See also ...
At what level should I cache results of jQuery DOM queries?