I have found this form of selector inside a plugin, can anyone explain it to me?
var container = $(this);
var myDiv = $('div', container);
The idea is to only select the div
element, why would it have the container
variable as well?
I have found this form of selector inside a plugin, can anyone explain it to me?
var container = $(this);
var myDiv = $('div', container);
The idea is to only select the div
element, why would it have the container
variable as well?
It is he context of the selector, it's like doing a .find()
EXAMPLE:
$("#selector", context) = $(context).find("#selector")
This question and answer appears to address your requirements for an explanation. How to get the children of the $(this) selector?. Essentially: The jQuery constructor accepts a 2nd parameter which can be used to override the context of the selection.