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"));
More Related Contents:
- Sort divs in jQuery based on attribute ‘data-sort’?
- What are the typical reasons Javascript developed on Firefox fails on IE? [closed]
- Replace Div with another Div
- Remove element from JS injected HTML
- Detecting input change in jQuery?
- jQuery, simple polling example
- how to get GET and POST variables with JQuery?
- Equivalent of String.format in jQuery
- How to scroll to top of page with JavaScript/jQuery?
- How to pass parameters in $ajax POST?
- How to select last child element in jQuery?
- Number input type that takes only integers?
- How to use jQuery to select a dropdown option?
- Does using $this instead of $(this) provide a performance enhancement?
- How can I run some javascript after an update panel refreshes?
- MVC DateTime validation – UK Date format
- JavaScript Scale Text to Fit in Fixed Div
- AngularJS group check box validation
- How do I get a fixed position div to scroll horizontally with the content? Using jQuery
- How can I use JSON data to populate the options of a select box?
- How to display an IFRAME inside a jQuery UI dialog
- Extending an existing jQuery function
- Combined total for multiple jQuery-UI Sliders
- Alert for unsaved changes in form
- new Image(), how to know if image 100% loaded or not?
- how to read json result in jquery?
- Trigger for span text/html on changed
- Center an Image vertically and horizontally using CSS
- How can I change text after time using jQuery?
- Rails accepts_nested_attributes_for with f.fields_for and AJAX