andyMatthews.net

Capturing the expand and collapse event on a jQuery Mobile collapsible set

This morning over at Goba.mobi I needed to capture the expanding/collapsing of a jQuery Mobile collapsible set. I wanted to add a class to an element, but only when a a specific set was opened. I Googled for a few minutes before finding a post over on the jQuery Mobile forums. Turns out it's pretty simple. Here's what I did.

In our case we're using form tags as the container, so that's what I bound my event to. I only cared about the expand event since I wanted to target the opening of a specific container, namely the Phone section. Next I used simple JavaScript property access (this.id) to check the id if the current target. Finally I added and removed a class as needed.

Pro-tip: Rather than applying a large number of attributes to an element with jQuery's css() method, consider creating a class for those styles. Then using the addClass()/removeClass() partner methods to add and remove the styling. Much simpler and it keeps your CSS out of your JavaScript code.

Chaussures Nike Pas Cher, Nike Air Force 1 Pas Cher, Nike Air VaporMax Pas Cher, Nike Air VaporMax Flyknit 3 Pas Cher, Nike Air VaporMax Plus Pas Cher, Nike Air VaporMax 360 Pas Cher, Nike Air VaporMax 2020 Pas Cher, Nike Air VaporMax 2021 Pas Cher, Nike Air VaporMax EVO Pas Cher, Nike Air Max Pas Cher, Nike Air Max 90 Pas Cher, Nike Air Max 95 Pas Cher, Nike Air Max 97 Pas Cher, Nike Air Max 2021 Pas Cher, Nike Air Max TN Pas Cher, Nike Air Max Plus Pas Cher, Nike Air Max Plus 3 Pas Cher | Zapatillas Nike Baratas, Nike Air Force 1 Baratas, Nike Air VaporMax Baratas, Nike Air VaporMax Flyknit 3 Baratas, Nike Air VaporMax Plus Baratas, Nike Air VaporMax 360 Baratas, Nike Air VaporMax 2020 Baratas, Nike Air VaporMax 2021 Baratas, Nike Air VaporMax EVO Baratas, Nike Air Max Plus Baratas, Nike Air Max Plus 3 Baratas, Nike Air Max 90 Baratas, Nike Air Max 97 Baratas, Nike Air Max 95 Baratas, Nike Air Max 1 Baratas