My fiddle: http://jsfiddle.net/b2stctr8/
The goal is to expand and collapse the target div by clicking on an image. My method is to start with a collapsed class with display:none. The javascript removes the class and allows the div to be displayed. The code works, but I've had a miserable time trying to animate the action. I'm loading jQuery and jQueryUI. This is my current code:
$('img.activator').click(
function(){
if ($('#mobileSelectors').hasClass('collapsed')) {
$('#mobileSelectors').removeClass('collapsed', 200);
} else {
$('#mobileSelectors').addClass('collapsed', 200);
}
});
Looking back at similar situations people have had on StackOverflow, I tried rearranging my function for switchClass and also with toggleClass as mentioned in solutions. I was unsuccessful. Any suggestions on how this function can be animated?