Creating a prototype function on a dom element