way better would be to pass the DOM nodes to swap between rather than ids, then you can just do a generic $(node1) which will work for both nodes and ids.