Updated for jquery version 1.7.0 and above