First pass to enable support for multiple elements

Caveats:
* For now this only updates the jQuery code
* My IDE removed some extra spaces, but the indents should be as they were