Anjum Anjum - 2 years ago 176
Javascript Question

JQuery Mobile to check if a Div is Expanded or Collapsed

I have a Div that is collapsible using attribute


How can I check at any point in time whether the Div is in Collapsed mode or Expanded mode. I tried this but it doesn't work:

if ($("#hideshow").is(":collapsed"))

Please note that
won't work because in both states visible returns true.

Answer Source

This is done via CSS. When a collapsible element is collapsed, it has the class "ui-collapsible-collapsed" added. Use .hasClass() to check it

if ($("#hideshow").hasClass('ui-collapsible-collapsed')) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download