I’m having trouble understanding a type of jQuery selection, and I hope someone can explain it to me in clear terms.
It’s taken from this Stack Overflow question.
Basically, it has the common jQuery: $( selector ).
But inside that it has $({ y: iFrameScrollY }).
I’ve never seen this before. What does it mean to have { ... } and someVal: anotherVal inside the brackets?
Also, please recommend a different title for this question, to make it easier for others to find it.
What
$({ y: iFrameScrollY })does is wrap a jQuery selector object around the JavaScript object{ y: iFrameScrollY }.The JavaScript object is declared
{ y: iFrameScrollY }, meaning it contains a property namedyset to the value ofiFrameScrollY.By wrapping the object into a jQuery object one can avail of executing jQuery methods against the wrapped object.
See this documentation for more details.