Skip to content

Instantly share code, notes, and snippets.

@ozrabal
Forked from carloscabo/flexslider_destroy.js
Created June 15, 2021 11:42
Show Gist options
  • Save ozrabal/72f0d62ff85b432864b955944ea42007 to your computer and use it in GitHub Desktop.
Save ozrabal/72f0d62ff85b432864b955944ea42007 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