-
-
Save liuxd/9554d614a47bc1b2474d93297a25521a to your computer and use it in GitHub Desktop.
[Reverse the elements in a target element] #jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.reverseChildren = function() { | |
return this.each(function(){ | |
var $this = $(this); | |
$this.children().each(function(){ $this.prepend(this) }); | |
}); | |
}; | |
$('#target').reverseChildren(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment