I need help understanding $(this). Is it possible to narrow the focus of \'this\' within the parentheses or does \"this\" preclude the use of any other attributes?
You can take a look at this: http://api.jquery.com/each/
Basically this
is the DOM element that the callback is referencing. You can't do $(this + " div")
because you are adding a string to an element. You first need to get the id like in your third code snippet.
By the way, $(this).children("div")
is not the same as $('#'+$(this).attr("id")+" div")
First off, this
might not have an ID, in which case the second way won't work at all. And even if it does have an ID, that second code is actualy $(this).find("div")
. If you want children only you have to do:
$('#'+$(this).attr("id") + " > div")