forming a 2D array in jquery -


i'm trying create 2d array consisting of url , text in "a href" element.

i think got working, not sure if correct structure 2d array. output in console, looks 1d array.

i need [link url, linktext]

example: [http://www.yahoo.com, yahoo!]

could please take , see if 2d array?

thanks

here jsfiddle:

http://jsfiddle.net/kxkhz/13/

var linkarray = []; $('[class=hrefurl]').each(function (i) {     var text = ($(this).text());     var url = ($(this).attr('href'));     linkarray.push(url, text); });  (var = 0; < linkarray.length; i++) {    console.log(linkarray[i]); } 

change

linkarray.push(url, text); 

to

linkarray.push([url, text]); 

or use objects instead of arrays inner element bit more structured:

linkarray.push({url: url, text: text}); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -