agjVersionless

MIT License Current Release Tested by QUnit Coveralls Coverage Issues npm Downloads Patreon

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.

Usage

Include the plugin after jQuery:

<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
<script src="https://agjVersionless.agjjQuery.org/distribution/jquery.agjVersionless.min.js"></script>

Then use the $.agjVersionless API:

// 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');

API

element.agjVersionless.bind(event, [data], fn) or $.agjVersionless.bind(element, event, [data], fn)

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) or $.agjVersionless.unbind(element, event)

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.

Contributing

Please read the contributing guidelines before submitting a pull request.

License

Copyright (c) 2026 Andrew G. Johnson andrew@andrewgjohnson.com

Licensed under the MIT License.