Reputation: 11431
Say i have 4 div's in an enclosing div. The div's inside have classes of div1, div2, div3, div4.
I want to save the order of these div's and then load the correct order the next time the page loads. (e.g. http://jquery-howto.blogspot.com/2010/09/jquery-cookies-getsetdelete-plugin.html)
So. My question is. What is the best way to turn this list of divs into an array to be stored in a cookie?
Code snippets would be appreciated.
Thanks
Upvotes: 0
Views: 95
Reputation: 66663
Something like:
var order = [];
$('#containerDiv').children().each(function() {
order.push($(this).attr('class'));
});
var orderString = order.join(","); // this will be div1,div2,div3 etc..
Upvotes: 1