Change #1 for compatibility with jquery >= 1.9