Skip to content
Advertisement

Toggle classes with this as an event handler in jQuery

I want to toggle the content class independently when I click the collapsible class button associated with it. I read briefly on using this in event handlers. The way I’ve used it so far, I end up toggling the collapsible class (i.e the button) instead.

JavaScript

This is close to what I want but instead of toggling the button I want to toggle the div when I click the button.

JavaScript

Advertisement

Answer

You can use this in conjunction with next() by specifying the class name of the button.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement