Refactored html and moved onclick event handler in JS file