Preserving link and default state using cookies
hello,
i not sure post re-design of forum; it's been while please forgive me if in wrong g place.
i have basic link wrapped in ul tag.
i using jquery give links color when clicked performing add/remove class function, link state preserved cookies if user returns page; shows tab viewing.
the problem is; single page , want set default link or tab; first one. not know how this.
this looking accomplished:
- a user visits page , first link colored red (default)
- if user clicks on link link becomes active , first link looses it's default status
- when user returns first link nolonger default, whatever link user selected when first visited; that's because link rememberd using cookies.
- the first link maintain default state if user deletes cookies or visits page first time.
here peice of jquery have used maintain selected state:
$(document).ready(function() {
var idactive = $.cookie('cookieactive');
if (idactive) {
$('#'+idactive).addclass('activelink');
}
$('ul li a').click(function() {
var id = $(this).attr('id');
$("ul li a").removeclass("activelink");
$(this).addclass("activelink");
$.cookie('cookieactive', id);
$.cookie('cookieactive', id, { expires: 10000});
});
});
i assume jquery working way want it, , problem how set default.
in case, give default link id, such "default". add else clause conditional statement in jquery:
if (idactive) {
$('#'+idactive).addclass('activelink');
} else {
$('#default').addclass('activelink');
}
More discussions in Dreamweaver support forum
adobe
Comments
Post a Comment