Uncaught TypeError: $(...).data(...) is undefined

I’m attempting to reverse the order of change events on a particular element:

<!-- HTML-->
<!DOCTYPE html>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

  <div id='button' style='width:40px;height:40px;background-color:red;'></div>


Here is the javascript with the html:


var clicks = $.data('#button', 'events').click.slice();
var button = $('#button').unbind('click');
$.each(clicks.reverse(), function() {


function first() { alert(“first”); };
function second() { alert(“second”); };
function third() { alert(“third”); };
This should fire the events in reverse: ‘third’, ‘second’, ‘first’.

When the button is clicked the line:

var clicks = $.data('#button', 'events').click.slice();

produces the error

Uncaught TypeError: $(…).data(…) is undefined.

Can someone please offer a correction to this code which will enable it to run on Firefox.