KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have something simple like this: $(selector).append("somestuff"); But since I'm going to reuse the selector I cache it with: var $selector = $(selector); So I end up with: $selector.append("somestuff"); My question is, should I be doing that, or should I be doing: var selector = $(selector); selector.append("somestuff"); Trying either one, both works. Which method is correct, and why? Is the $ in $selector unnecessary because the jquery object has already been declared in $(selector) ? Edit Thanks for the answers. It seems very simple and quite clear. Still, there seems to be disagreement over whether or not I should use $ in the variable. It would be nice for everyone to vote up an answer. :)
Tags (comma-separated)
Save Edits
Cancel