Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
192
rated 0 times [  199] [ 7]  / answers: 1 / hits: 8041  / 10 Years ago, fri, march 7, 2014, 12:00:00

I have a Div that is collapsible using attribute data-role=collapsible



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))
alert(collapsed);


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


More From » jquery

 Answers
16

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')) {
alert(collapsed);
}

[#47088] Thursday, March 6, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brennonr

Total Points: 124
Total Questions: 101
Total Answers: 101

Location: Estonia
Member since Wed, Jun 8, 2022
2 Years ago
;