Ok saddle up cowboys, because this is going to be a long one. I have been spending the morning going through some of my old code and I\'m left wondering about best practices
I'll try to answer these as concisely as possible:
Cache it when it's used often, especially in a loop situation, running the same code to get the same result is never a good thing for performance, cache it.
Use this
when you only need a DOM element and $(this)
when you need the jQuery methods (that wouldn't be available otherwise), your example of this.id
vs $(this).attr("id")
is perfect, some more common examples:
this.checked
instead of $(this).is(':checked')
$.data(this, 'thing')
instead of $(this).data('thing')
Decending from an ID selector is preferred for performance...how specific do you need to be? That completely depends, in short: be as specific as you need to be.