i just need a little help about accordion. What I want is how can I collapse all the accordion by default when the page is loaded? My goal is to display all the accordion contents always. How can I do that? Here's what I did in my code.
<script>
$(function() {
$( "#accordion" ).accordion({
collapsible: true,
autoHeight: false,
active: false
});
});
</script>
<div id="accordion">
<h3>MASTER LIST</h3>
<div>
<?php
echo anchor('category_controller/homepage','Categories');
echo "<br />";
echo anchor('item_controller/index','Items');
echo "<br />";
echo anchor('supplier_controller/index','Suppliers');
echo "<br />";
echo anchor('product_controller/index','Product');
echo "<br />";
echo anchor('#','Customers');
echo "<br />";
echo anchor('#','Depot');
echo "<br />";
echo anchor('h2morders/view','Reports');
echo "<br />";
?>
</div>
<h3>LIST</h3>
<div>
<?php
echo anchor('pricelist_controller/index','Price List');
?>
</div>
<h3>HISTORY</h3>
<div>
<?php
echo anchor('pricelist_controller/price_history','Price History');
?>
</div>
<h3>TRANSACTIONS</h3>
<div>
<?php
echo anchor('#','Inventory');
echo "<br />";
echo anchor('#','Material Transfer');
echo "<br />";
echo anchor('#','Material Return');
echo "<br />";
echo anchor('#','Disposal');
echo "<br />";
echo anchor('#','Order');
echo "<br />";
echo anchor('#','Delivery Receipt');
echo "<br />";
echo anchor('#','Material Issuance');
echo "<br />";
?>
</div>
<h3>LEDGERS</h3>
<div>
<?php
echo anchor('c','Items Ledger');
echo "<br />";
echo anchor('c','General Ledger');
echo "<br />";
?>
</div>
</div>
</div>
try this :
Add the active: false option documentation
$("#accordion").accordion({collapsible: true, active: false });
$( ".selector" ).accordion( "option", "active", false);
Docs :
Setting active to false will collapse all panels. This requires the collapsible option to be true.
尝试这个
$( ".selector" ).accordion( "option", "collapsible", true );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.