Convert Prototype.js code to jQuery