I\'m writing some jquery code to toggle a Div visibility. I followed the method posted here: http://jsfiddle.net/Ga7Jv/.
When the user clicks an image (next to a H2
If you want to switch class names in the same element, better to have one another fixed class in it and keep changing the other ones.
here is what I am saying:
$(function(){
$(".toggler").on("click", function(){
$(this)
.toggleClass("expander expanded")
.parent().next().slideToggle();
});
});
TIP:
Here .toggler is the fixed class for the trigger element and I am switching .expander and .expanded classes in it.
Also, you are selecting wrong element for slideToggle. #TableData is .parent().next().
Working Demo : http://jsfiddle.net/ashishanexpert/nuw2M/1/