let say I want to do this:
var dashboard = {};
var page = \"index\";
$(\'.check\').click(function(){
$(thi
$.extend is the way to go
function elem(a,b){
var r={'pages':{'pagename':{}}};
r.pages.pagename[a]={'show':b};
return r;
}
data={};
//inside the event handler or something:
data = $.extend(true,data,elem($(this).closest('li').attr("id"),$(this).is(":hidden") ? 'collapsed' : 'expanded'));
But honestly - this is a rather messy idea to store this information anyway. I bet that if You need that information later it could be done with a good selector or with jQuery.data()