jQuery is an array-like object that contains all of your matched elements. Often jQuery will by default apply its changes to the first element of the collection:
$("li").css("display"); // display val of first element, not all elements.
Although many li elements could be found, the jQuery object tells us the first implicitly. We could directly tell him this using the $.get method:
$("li").get(0); // Returns first DOM element $("li")[0]; // Also returns first DOM element
We can check the nodeName to check this:
$("li").get(0).nodeName; // LI $("li")[0].nodeName; // LI
If we look under the covers, we will see how $.get() is implemented:
get: function(num) { return num == null ? this.toArray() : ( num < 0 ? this[ this.length + num ] : this[ num ] ); }
This shows that when the argument is not provided, the entire collection of elements is converted to an array and then returned. When an argument is provided, for example 2 , we return the element as index 2. If -2 supplied, this is added to the length (suppose the length is 5, 5 + (- 2) is 3) and the resulting number is used as the index.
So, regarding your specific example:
var shuffle = $("#shuffle")[0]; shuffle.play();
jQuery is used to get any element that has an id shuffle value. This returns an object similar to a jQuery array. But your play() method does not exist in the jQuery object, it exists in the #shuffle object. So you need to get the first item in the collection.
You can use $.get(0) , however, as we just saw, this will just add one more step. Internally, jQuery would execute the same code that you are executing above, [0] .