RailsSon
RailsSon

Reputation: 20637

Jquery Accordion - Manual Activate

I am using the Jquery Accordion plugin.

I would like to when the page is loaded open a certain panel.

I am trying to this like so, by identifying it by ID:

selected = $("#1")
  $('ul.accordiontasks').accordion( {
    autoHeight: false,
    active: selected
  });

This does not seem to activate the accordion panel with the ID 1, can anyone see what I am doing wrong and maybe point me in the right direction?

Cheers

Eef

Upvotes: 0

Views: 1443

Answers (2)

hgmnz
hgmnz

Reputation: 13306

You can always trigger it:

$("#1").trigger("click");

Upvotes: 4

tvanfosson
tvanfosson

Reputation: 532465

HTML element ids can't start with numbers (ref), they have to start with letters. If your code snippet is accurate then your HTML isn't. Note also that you don't need to supply an element, you can supply the selector directly.

$('ul.accordiontasks').accordion( {
    autoHeight: false,
    active: '#menu1'
});

Upvotes: 4

Related Questions