Okay, normally I would consider myself an intermediate user of jquery, but this seems like a very noob issue that I'm not quite sure how to code.
I have one div that I want to run a function against. The only way I'm aware of how to do this is something like...
$("#divname").each(function(){
dostuff();
});
This seems like a bit more work when I know there will only be one element. I tried this...
$("#divname", function(){
console.log($(this));
});
... but it writes out the whole dom. I just want to run the function on this one element. How do I do that?
doStuffas a callback later on in other jQuery iterations since you refer to a parameter rather thanthis. See my answer for details.doStuffin a call toeach, so I assume it's a function he wants to be able to run on many items, but also run explicitly on one item.:)And by the way, it looks like he accept my style answer and not yours... :)