I'm trying to get an array of jquery object from a selector, so I don't have to re-query them again to change later.
But while testing the code, I found that the jquery selector returns an array as an html element if it does not request a specific element.
<div id='nav'>
<div class='menu'>menu 1</div>
<div class='menu'>menu 2</div>
<div class='menu'>menu 3</div>
<div class='menu'>menu 4</div>
<div class='menu'>menu 5</div>
</div>
$('#nav .menu:eq(0)').html('haha');
$('#nav .menu').get(0).html('halo w');
-> Uncaught TypeError: Object #<HTMLDivElement> has no method 'html'
My question is why it returns an html element, not a jquery object. How can I get an array of jquery objects from a selector.
Here is an example JSFiddle.
http://jsfiddle.net/mochatony/K5fJu/7/
source
share