Skip to content

Instantly share code, notes, and snippets.

@franklinjavier
Created September 6, 2013 20:26
Show Gist options
  • Save franklinjavier/6469496 to your computer and use it in GitHub Desktop.
Save franklinjavier/6469496 to your computer and use it in GitHub Desktop.
Remove atributos html passando regex como parametro
/*
* Remove atributos html passando regex como parametro
*/
$.fn.removeAttrs = function( regex ) {
return this.each(function() {
var $this = $(this),
names = [];
$.each( this.attributes, function( i, attr ) {
if ( attr.specified && regex.test( attr.name ) ) {
$this.removeAttr( attr.name );
}
});
});
};
$('div').removeAttrs(/^data-/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment