I'm trying to switch out an ID (and I know a class would be better but in this case I need to use an ID) for a product listing template. Unfortunately it only works on the first click. I am unable to switch back once done. What am I doing wrong?Here is the code I am using\[code\]$(document).ready(function(){ $("a.toggle").bind("click", function(e){ e.preventDefault(); var theid = $(this).attr("id"); var thecontainer = $("div#container"); if($(this).hasClass("active")) { return false; } else { if(theid == "gridView") { $(this).addClass("active"); $("#listView").removeClass("active"); thecontainer.removeAttr('id'); thecontainer.attr('id', 'container'); } else if(theid == "listView") { $(this).addClass("active"); $("#gridView").removeClass("active"); thecontainer.removeAttr('id'); thecontainer.attr('id', 'containerList'); } } });});\[/code\]And here is the html for the links I am using to toggle the view.\[code\] <div class="buttonPanel"> <a id="gridView" class="btnGridView toggle active" href="http://stackoverflow.com/questions/12754339/#">Grid</a> <a id="listView" class="btnListView toggle" href="http://stackoverflow.com/questions/12754339/#">List</a> </div>\[/code\]The CSS is pretty lengthy but in short there are two versions for a grid view with boxes and functions, and a straight list view.