Example usage of options:
// Initializing collapse plugin // with custom open/close methods, // persistence plugin and accordion behaviour $("#demo").collapse({ open: function() { // The context of 'this' is applied to // the collapsed details in a jQuery wrapper this.slideDown(100); }, close: function() { this.slideUp(100); }, accordion: true, persist: true }); Events Binding eventsYou can listen for the opened and closed events on a collapsed collection.
$("#demo").bind("opened", function(e, section) { console.log(section, " was opened"); }); $("#demo").bind("closed", function(e, section) { console.log(section, " was closed"); }); Triggering eventsYou can manually trigger an open, close or toggle event to change the state of a section:
$("#demo").trigger("open") // open all sections $("#demo").trigger("close") // close all sections $("#demo h2 a").last().trigger("toggle") // toggle last sectionWhen a section changes state, it will trigger either an “opened” or “closed” event in return, depending on it’s new state.
API methodsIf you’re using vanilla JavaScript to instantiate the plugin, you’ll get direct access to the open, close and toggle methods.
var demo = new jQueryCollapse($("#demo")); // Initializing plugin demo.open(); // Open all sections demo.close(); // Close all sections demo.open(0); // Open first section demo.open(1); // Open second section demo.close(0); // Close first section demo.toggle(1); // Toggle second section 相关链接本文系作者 问说网 授权问说网发表,并经问说网编辑,转载请注明出处和 本文链接。
本站文章除注明转载外,均为本站原创或翻译,欢迎任何形式的转载,但请务必注明出处,尊重他人劳动。
转载请注明:文章转载自:问说网 » jQuery Collapse轻量级的手风琴菜单插件
本文标题:jQuery Collapse轻量级的手风琴菜单插件
本文地址:
顶 1 踩 1
交流:问说网设计交流群:12043441(快速加入),与众多设计师交流设计,分享素材。
设计微博:@问说网 欢迎关注获取网页设计资源、下载顶尖设计素材。