Is there a native jQuery function to switch elements?

Here’s an interesting way to solve this using only jQuery (if the 2 elements are next to each other):

$("#element1").before($("#element2"));

or

$("#element1").after($("#element2"));

Leave a Comment