Alternative to jQuery toggle function