Simplified JavaScript code by incorporating in jQuery calls.