According to jQuery documentation
ID Selector
Description: Selects a single element with the given id attribute.
When you have this markup
<div id="mydiv"></div>
And you do
alert($('#mydiv')); // displays "[Object]"
alert($('#mydiv')[0]); // displays "[HTMLDivElement]"
Since we expect 1 element, what is the explanation for the array notation? What makes the two different?
NOTE: Am more concerned about why we have array/collection of DIV when we only expected one.
Is [Object] = Array {HTMLDivElement}
. What is the structure of [Object]
?