Skip to content

Instantly share code, notes, and snippets.

@philcon93
Last active October 9, 2017 06:18
Show Gist options
  • Save philcon93/a34df1b5a67111423714ffe91f4b9159 to your computer and use it in GitHub Desktop.
Save philcon93/a34df1b5a67111423714ffe91f4b9159 to your computer and use it in GitHub Desktop.
Extend Jquery fucntionality

Extend jQuery

JS

Extend jQuery functionality to use functions globally but not increasing global name space.

jQuery.extend({
    percentage: function(a, b) {
        return Math.round((a / b) * 100) + '%';
    }
});

$.percentage(31.04, 100);
// "31%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment