Suppose there is some HTML code:
<div id="main"> <div id="sub1">123</div> <div id="sub2">456</div> <div id="sub3">789</div> </div> You need to save each sub* block into an array object in order to access these blocks later. For example:
var i = 0; var arr = {}; $('#main').find("div").each(function() { arr[i] = {'elem':$(this)}; i++; }); But how now, for example, to get access to an element, say number 3, if now we have an object, and not an HTML node?
arr[3].а_дальше_что? I want it to be something like this: arr[3].text(); // get block text
var arr = [];- Igormapfunction is more suitable for you. - Vadim Ovchinnikov