Skip to content

Instantly share code, notes, and snippets.

@joelbrennan0
Last active March 2, 2017 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelbrennan0/9eb737fc899eff05dfe7f6468a6a8acc to your computer and use it in GitHub Desktop.
Save joelbrennan0/9eb737fc899eff05dfe7f6468a6a8acc to your computer and use it in GitHub Desktop.
JavaScript Function Move HTML Element - Reorder
// Move an element withing the DOM at 992 window width - additional CSS required
var moveHtmlElement = function(init_el, add_cl, rm_cl, target_el, return_el) {
if ($(window).width() < 992) {
$(init_el).addClass(add_cl);
$(init_el).removeClass(rm_cl);
$(init_el).insertAfter(target_el);
} else {
$(init_el).addClass(rm_cl);
$(init_el).removeClass(add_cl);
$(init_el).insertAfter(return_el);
}
}
//moveHtmlElement('.m-changeable', 'm-block pull-right ad', 'm-none', '.navbar-header', '#before-btns');
//resise checker
//$( window ).resize(function() {
// moveHtmlElement('.m-changeable', 'm-block pull-right ad', 'm-none', '.navbar-header', '#before-btns');
//});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment