Examples/Demo
agjVersionless is designed to be easily integrated into existing projects quickly and without compatibility issues or any other conflicts. Because it’s a jQuery plugin you will first need to include an HTML reference to the jQuery JavaScript library if you don’t already have one. From there, simply add an HTML reference to jquery.agjVersionless.js to start using the agjVersionless plugin.
<!-- Reference to the jQuery JavaScript library -->
<script type="text/javascript" src="//code.jquery.com/jquery-4.0.0.min.js"></script>
<!-- Reference to the agjVersionless jQuery plugin -->
<script type="text/javascript" src="//agjVersionless.agjjQuery.org/distribution/jquery.agjVersionless.min.js"></script>
All of the examples below have interactive demos for you to try out.
Example One: Counter
To bind an event handler (e.g. when an element is clicked) simply select a jQuery element and call its agjVersionless.bind() function. Alternatively you can call the $.agjVersionless.bind() function directly and pass your element as the first parameter. This code will work across jQuery 1, 2, 3 and 4 with no need for reverse compatibility considerations.
HTML Source & JavaScript Source
HTML Source & JavaScript Source
Example Two: All the Functions
This example demonstrates all four available functions. $.agjVersionless.bind() and its alias $.agjVersionless.on() attach an event handler to an element; $.agjVersionless.unbind() and its alias $.agjVersionless.off() remove it. All four work identically across jQuery 1, 2, 3 and 4.