The toggle() method is a jQuery methods which is used to toggles between hide() and show() for the selected elements. This method checks the selected elements for visibility. show() is run if an element is hidden. hide() is run if an element is visible – This creates a toggle effect

Hide and Show in jQuery – Bajrangi Tech