Recently I had to do the migration of some javascript code written using Prototype and Scriptaculous to JQuery. The process wasn’t straightforward but wasn’t very difficult either. I jotted down a bunch of differences I had to deal with and thought of putting them together here.
Feature | Prototype/Scriptaculous | JQuery |
---|---|---|
ID Selector | id | #id |
appending a node | appendChild | append |
cloning array | Array.clone | Array.slice |
Setting css style values | elem.style.prop=value | elem.css(prop,value) |
Getting parent node | elem.parentNode | elem.parent() |
Utility methods for an element | Element.Methods.getHeight for example | elem.height() |
Removing a node | node.parentNode.removeChild(node) | node.remove() |