In this question, the following code is used –
var parent = $("#jcontent");
var button1 = $(".button1", parent) ;
to select a button of class button1 within the parent of id jcontent.
Why does this work? How does passing a jQuery object as a parameter to a jQuery selector tell it to select within that object? Can someone link to the docs which explain this function?
It’s the
contextparameter for the core method call.The parameter is described as:
And then there’s a section labelled “Selector Context,” which starts with: