Adding javascript like this works but it is better to use a JS file and use JQuery to add an event listener. check out this http://api.jquery.com/click/