I have a simple add attribute function:
$(\".list-toggle\").click(function() { $(\".list-sort\").attr(\'colspan\', 6); });
My question is:
$('.list-toggle').click(function() { var $listSort = $('.list-sort'); if ($listSort.attr('colspan')) { $listSort.removeAttr('colspan'); } else { $listSort.attr('colspan', 6); } });
Here's a working fiddle example.
See the answer by @RienNeVaPlus below for a more elegant solution.