I'd like to use a button to toggle some style on and off for some selected elements. I can add the style, like so:
$(".button").click(function() {
$(".elements").each(function() {
var height = $(this).data("height");
$(this).css({ 'height': height, 'background-color': "#ccc" });
});
});
However, I'm not sure how to toggle the style to "off" (remove the styling I have just applied).
I've tried to use the following solution (jQuery toggle CSS?), but I'm not sure that it will work in this case as I'm using a function to gather a style attribute from within the data
attribute of each element.
What would be the best way to do this with jQuery?