washer may or may not work

my washer will fill and work but only if I jiggle the cycle switch and after a while it just stops completly. I’ll turn the timer and hear a humming noise and then nothing:confused: