agjVersionless
Description
agjVersionless is a plugin for the jQuery JavaScript library to handle functionality regardless of jQuery version. Works with jQuery 1, 2, 3 and 4.
agjVersionless is an agjjQuery.org plugin.
Examples
// Bind an event handler regardless of jQuery version
$('#my-element').agjVersionless.bind('click', function() {
console.log('clicked');
});
// Unbind an event handler regardless of jQuery version
$('#my-element').agjVersionless.unbind('click');
If you need to support IE6, IE7 or IE8, use the $.agjVersionless form instead as element.agjVersionless relies on Object.defineProperty which those browsers do not support on plain objects:
// Bind an event handler regardless of jQuery version (IE6+ compatible)
$.agjVersionless.bind($('#my-element'), 'click', function() {
console.log('clicked');
});
// Unbind an event handler regardless of jQuery version (IE6+ compatible)
$.agjVersionless.unbind($('#my-element'), 'click');
JavaScript Functions
We use the dollar sign alias ($) instead of the jQuery global for documentation but either can be referenced.
element.agjVersionless.bind(event [, data], fn) / $.agjVersionless.bind(element, event [, data], fn)
// Bind an event handler regardless of jQuery version
$('#my-element').agjVersionless.bind('click', function() {
console.log('clicked');
});
// Bind an event handler regardless of jQuery version (IE6+ compatible)
$.agjVersionless.bind($('#my-element'), 'click', function() {
console.log('clicked');
});
Binds an event handler to an element regardless of jQuery version. Works with jQuery 1, 2, 3 and 4. Note that the element.agjVersionless form requires IE9 or later; use $.agjVersionless if you need to support IE6, IE7 or IE8.
element.agjVersionless.unbind(event) / $.agjVersionless.unbind(element, event)
// Unbind an event handler regardless of jQuery version
$('#my-element').agjVersionless.unbind('click');
// Unbind an event handler regardless of jQuery version (IE6+ compatible)
$.agjVersionless.unbind($('#my-element'), 'click');
Unbinds an event handler from an element regardless of jQuery version. Works with jQuery 1, 2, 3 and 4. Note that the element.agjVersionless form requires IE9 or later; use $.agjVersionless if you need to support IE6, IE7 or IE8.
Usage/Installation
You will need an HTML reference to jQuery in order for the plugin to function.
<!-- Reference to the jQuery JavaScript library -->
<script type="text/javascript" src="//code.jquery.com/jquery-4.0.0.min.js"></script>
With npm or Yarn
This plugin offers support for the npm and Yarn dependency managers. You can find the agjVersionless package online on npmjs.com.
Install using npm
Run this command to install the plugin using npm:
npm install @agjjquery/agjversionless
Install using Yarn
Run this command to install the plugin using Yarn:
yarn add @agjjquery/agjversionless
Once installed you can start using agjVersionless within your project by adding an HTML reference to the plugin’s JavaScript file.
<!-- Reference to the agjVersionless jQuery plugin -->
<script type="text/javascript" src="./node_modules/@agjjquery/agjversionless/distribution/jquery.agjVersionless.min.js"></script>
Without npm or Yarn
To use without npm or Yarn add an HTML reference to the JavaScript source which you will need to download and host. Run this command to download it via the terminal:
curl -o jquery.agjVersionless.min.js 'https://cdn.jsdelivr.net/npm/@agjjquery/agjversionless/distribution/jquery.agjVersionless.min.js'
Once downloaded, you must reference the file in your HTML:
<!-- Reference to the agjVersionless jQuery plugin -->
<script type="text/javascript" src="jquery.agjVersionless.min.js"></script>
Unit Testing
The plugin uses jQuery’s QUnit framework for unit testing. All units tests are located in the qunit.js file. The unit tests can be run online in-browser at agjVersionless.agjjQuery.org/tests/index.html. We aim for 100% code coverage.
Help Requests
Please post any questions in the discussions area on GitHub if you need help.
If you discover a bug please enter an issue on GitHub. When submitting an issue please use our issue templates.
Contributing
Please read our contributing guidelines if you want to contribute.
You can contribute financially by becoming a patron at patreon.com/agjopensource to support agjVersionless and other agjjQuery.org plugins.
Acknowledgements
This plugin was started by Andrew G. Johnson (@andrewgjohnson).
Full list of contributors:
Our security policies and procedures come via the atomist/samples project. Our issue templates come via the tensorflow/tensorflow project. Our pull request template comes via the stevemao/github-issue-templates project. The Jekyll theme was released by Andrew G. Johnson.
Changelog
You can find all notable changes in the changelog.







