$('button').on('click', function() {
alert('button was clicked!');
});
//more flexible way of adding an event listener;
//using the .on method
$('h1').on('mouseover', function(){
$('h1').css('color', '#'+Math.floor(Math.random()*16777215).toString(16));
})//the above changes your h1 elements color property to a random color
//but other events can be used as well. see source and below
//Guess what this does
$(document).on('keypress', function(event){
if (event.key === 'a') {
console.log('move left function...');
$('h1').css('color', '#'+Math.floor(Math.random()*16777215).toString(16));
}
})
//Answer Below
//everytime you press 'a' the text in your h1 becomes a different color
function notify () {
alert("clicked" );
}
$("button").on("click", notify );