Fix memory leak with reduced variable scope

`elem` is being set in the outer scope but is only used in the modified jQuery methods so the last one bleeds out and as such am seeing detached DOM tree referenced by that there variable.

![](https://f.cloud.github.com/assets/441581/1623822/e0098812-56b8-11e3-8f17-4256e74482ac.png)