Skip to content

Instantly share code, notes, and snippets.

@carloscabo
Created September 28, 2015 14:50
Show Gist options
  • Save carloscabo/0a6b76537eeb6bf4ee82 to your computer and use it in GitHub Desktop.
Save carloscabo/0a6b76537eeb6bf4ee82 to your computer and use it in GitHub Desktop.
Destroy flexslider carousel
function flexdestroy(selector) {
var $els = $(selector);
$els.each(function() {
var $el = $(this);
var $elClean = $el.clone();
$elClean.find('.flex-viewport').children().unwrap();
$elClean
.removeClass('flexslider')
.find('.clone, .flex-direction-nav, .flex-control-nav')
.remove()
.end()
.find('*').removeAttr('style').removeClass(function (index, css) {
// If element is SVG css has an Object inside (?)
if (typeof css === 'string') {
return (css.match(/\bflex\S+/g) || []).join(' ');
}
});
$elClean.insertBefore($el);
$el.remove();
});
}
// flexdestroy('#slider'); // Replace with your selector/s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment