Skip to content

Instantly share code, notes, and snippets.

@RyanNutt
Created January 29, 2020 17:06
Show Gist options
  • Save RyanNutt/0967c495a04fb8d47483d456ffef4826 to your computer and use it in GitHub Desktop.
Save RyanNutt/0967c495a04fb8d47483d456ffef4826 to your computer and use it in GitHub Desktop.
jQuery plugin to move elements to top or bottom of parent
/**
* Move an element to the top of the stack by appending it to the end
* of its parent.
*
* The element, and its siblings, should be positioned in parent so that
* they're stacked on top of each other.
*/
(function ($) {
$.fn.moveToBottom = function () {
return this.parent().prepend(this);
};
$.fn.moveToTop = function () {
return this.parent().append(this);
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment