function to toggle list by click