javascript - jQuery collapsable element implementation -
i'm new jquery , wanted find out if implementation of jquery collapse:
$(function () { var collapse = { "body" : $(".collapse-body"), "container" : $(".collapse-container"), "trigger" : $(".trigger"), "show" : $(".is-collapse"), "speed" : 300 }; function iscollapse() { return $(collapse.body).hasclass("is-collapse"); } function iscollapsesingle() { return $(collapse.container).hasclass("collapse-single"); } function collapseshow() { if (iscollapse()) { collapse.show.show(); } }$(document).ready(function(){collapseshow()}); // $(collapse.trigger).click(function (id) { id.preventdefault(); var atv = $(this).attr("href"); $(atv).slidetoggle(collapse.speed); if (iscollapsesingle()) { $(collapse.body).not(atv).slideup(collapse.speed); } }); });
Comments
Post a Comment