Implemented following changes :

1. Used $ before variable name if it stores jQuery object.
2. .not() funciton is removed and used :hidden instead with some change in
logic.
3. Removed the loop to add click event as jQuery will itself iterate over
the array to add the click event.