updated for jquery 1.9, 1.10 and 2