Home >Web Front-end >HTML Tutorial >About accordion_html/css_WEB-ITnose in UI
Write a cookie
$(window).bind('unload', function(){ //clean up and persist on page unload
$('.' config ["headerclass"]).unbind()
var expandedindices=[]
$('.' config["contentclass"] ":visible").each(function(index){ //get indices of expanded headers
expandedindices.push($(this).attr('contentindex'))
})
if (config.persiststate==true && $('.' config["headerclass"]) .length>0){ //persist state?
expandedindices=(expandedindices.length==0)? '-1c' : expandedindices //No contents expanded, indicate that with dummy '-1c' value?
ddaccordion.setCookie(config.headerclass, expandedindices)
}
})
Very bad, it only records when unloading that the panel is closed
ddaccordion.setCookie(config. headerclass, expandedindices)
Write a cookie
$(window).bind('unload', function(){ //clean up and persist on page unload
$('. ' config["headerclass"]).unbind()
var expandedindices=[]
$('.' config["contentclass"] ":visible").each(function(index){ //get indices of expanded headers
expandedindices.push($(this).attr('contentindex'))
})
if (config.persiststate==true && $('.' config["headerclass" ]).length>0){ //persist state?
expandedindices=(expandedindices.length==0)? '-1c' : expandedindices //No contents expanded, indicate that with dummy '-1c' value?
ddaccordion.setCookie(config.headerclass, expandedindices)
}
})
Very bad. It only records when unloading that the panel is closed
ddaccordion.setCookie( config.headerclass, expandedindices)
Thank you, so it is achieved by setting and reading cookies? Right?
Yes, look at that code
ddaccordion.setCookie(config.headerclass, expandedindices)
This method is to write the cookie package
when loading the page There is also getCookie
Yes, look at that code
ddaccordion.setCookie(config.headerclass, expandedindices)
In this method, the cookie package is written
When the page is loaded, There is getCookie
Thank you very much! !