We are going to add a click listener, inside Atom, inside index.js, and we're going to add some code down near the bottom.
Now the first thing I want to do is create a variable, and I'm going to call this variable locationButton; this is going to store our selector. This is the jQuery selector that targets the button we just created, because we're going to need to reference it multiple times and storing it in a variable saves the need to make those calls again. We're going to call jQuery like we've done for our other selectors, passing in one argument, a string, and we're selecting something by ID, which means we got to start with that hash sign (#), and the actual ID is send-location:
var locationButton = jQuery('#send-location');
Now that we have this in place we can go ahead and do whatever we like. In our case, what we're going to be doing is add a click event, and we want to do something when someone clicks that button. To get that done we're going to go to locationButton.on:
var locationButton = jQuery('#send-location');
locationButton.on
locationButton.on is going to be our event listener. We're listening for the click event, inside quotes for the first argument, and the second argument as always is going to be our function:
var locationButton = jQuery('#send-location');
locationButton.on('click', function () {
});
This function is going to get called when someone clicks the button.