While trying to get a better understanding of JQuery
I came across this question
What I got from it was the JQuery
selector returns an array-like structure that you can iterate over like an array. My question is under what circumstances can I do something like this:
$('.foo')[1].someFunction();
without causing the error: $(...)[1].someFunction is not a function
(someFunction
refers to a defined JQuery
function like appendTo()
or text()
) .
Also why will it cause an error and whats the best method (if possible) of chaining a function after using []
notation?