Add event handling in javascript