Updated to work on jQuery 1.9+ and tested on 2.1.1

Made the necessary minor changes to get this working with newer versions of jQuery.