أكورديون jQuery الديناميكي
-
23-09-2019 - |
سؤال
كيف يمكنني إغلاق الأكورديون عند بدء التشغيل. هنا هو عرض العينة هنا
هنا هو الرمز:
<script>
$(function() {
$("#accordion").tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide'});
});
</script>
<script>
// add new effect to the tabs
$.tools.tabs.addEffect("slide", function(i, done) {
// 1. upon hiding, the active pane has a ruby background color
this.getPanes().slideUp("slow").css({backgroundColor: "#fff"});
// 2. after a pane is revealed, its background is set to its original color (transparent)
this.getPanes().eq(i).slideDown("slow", function() {
$(this).css({backgroundColor: 'transparent'});
// the supplied callback must be called after the effect has finished its job
done.call();
});
});
</script>
المحلول
يمكنك أن تفعل ذلك مثل هذا:
$("#accordion")
.tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide', collapsible: true})
.tabs('select', false);
هذا يمثلها collapsible
, ، ثم يحدد علامة تبويب ليست موجودة لعرضها ، باستخدام false
.
نصائح أخرى
ضع في CSS:
#accordion div.pane: display:none;
لا تنتمي إلى StackOverflow