/    Sign up×
Community /Pin to ProfileBookmark

Hi I have this code below.
What I need to do and can not figure it out is, when a person first goes to a page and no cookie is found, i want it to show all div expaned, right now they are all staying close.
Please help I been trying to figure this out all day long.

[code=html]

(function($) {
$.fn.extend({
collapse: function(options) {

var defaults = {
inactive : “inactive”,
active : “active”,
head : “.demo”,
group : “.power1”,
speed : 300,
cookie : “collapse3”
};
// Set a cookie counter so we dont get name collisions
var op = $.extend(defaults, options);
cookie_counter = 0;

return this.each(function() {

// Increment cookie name counter
cookie_counter++;

var obj = $(this),
sections = obj.find(op.head).addClass(op.inactive),
panel = obj.find(op.group).hide(),
l = sections.length,
cookie = op.cookie + “_” + cookie_counter;

// Look for existing cookies

for (c=0;c<=l;c++) {
var cvalue = $.cookie(cookie + c);
if ( cvalue == ‘open’ + c ) {
panel.eq(c).show();
panel.eq(c).prev().removeClass(op.inactive).addClass(op.active);
};
};
sections.click(function(e) {
e.preventDefault();
var num = sections.index(this);
var cookieName = cookie + num;
var ul = $(this).next(op.group);
// If item is open, slide up
if($(this).hasClass(op.active)) {
ul.slideUp(op.speed);
$(this).removeClass(op.active).addClass(op.inactive);
$.cookie(cookieName, null, { path: ‘/’, expires: 10 });
return
}
// Else slide down
ul.slideDown(op.speed);
$(this).addClass(op.active).removeClass(op.inactive);
var cookieValue = ‘open’ + num;
$.cookie(cookieName, cookieValue, { path: ‘/’, expires: 10 });

});

});
}
});
})(jQuery);

[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@pattywomenauthorFeb 21.2011 — Please can someone help me.

What I was thinking is maybe check to see if cookies is set for this page, and if no cookie for this page is found, open all div's

Can anyone help me with this please
Copy linkTweet thisAlerts:
@pattywomenauthorFeb 21.2011 — Come one please, someone must be smart enough to figure this out for me please.

Cant believe no one online in here can't figure this out.

I am to new at this to even figure it out period.
×

Success!

Help @pattywomen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...