Hiding divs when loading a page using the jQuery UI Accordion widget

I am using jQuery Accordion. When the page loads, all decks flash for a second before hiding. I would like divs to remain hidden during loading. I thought I was doing this by setting them to hidden through javascript outside the document, ready to check like this:

$('#accordion div').hide();
$('#accordion2 div').hide();

jQuery(document).ready(function($) {...

However, this does not work, and I suspect, because I am using $ shortcut, not yet declared.

How do I get the hide () functions to start when the page loads, rather than waiting until the full load and then hide the divs?

Thank!

+3
source share
2 answers

, , , . , , , .

CSS, , , :

<style type="text/css">

#accordion div, #accordion2 div { display: none; }

</style>
+7

, :

$('#accordion div').hide();
$('#accordion2 div').hide();

jQuery :

$(function(){
    $('#accordion div').hide();
    $('#accordion2 div').hide();
});

, , html-

+3

All Articles