revised javascript to jquery