Skip to content

Instantly share code, notes, and snippets.

@dustinpoissant
Created January 31, 2017 23:04
Show Gist options
  • Save dustinpoissant/b26a677ad21d761fe36fe76a23b74ed7 to your computer and use it in GitHub Desktop.
Save dustinpoissant/b26a677ad21d761fe36fe76a23b74ed7 to your computer and use it in GitHub Desktop.

Revisions

  1. dustinpoissant created this gist Jan 31, 2017.
    9 changes: 9 additions & 0 deletions attrs.jquery.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    $.fn.attrs = function(){
    var attributes = {};
    if(this.length){
    $.each( this[0].attributes, function( index, attr ) {
    attributes[ attr.name ] = attr.value;
    });
    }
    return attributes;
    };
    1 change: 1 addition & 0 deletions attrs.jquery.min.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    $.fn.attrs=function(){var a={};return this.length&&$.each(this[0].attributes,function(b,c){a[c.name]=c.value}),a};