How can I hide/show a div when a button is clicked?

前端 未结 8 1941
陌清茗
陌清茗 2020-12-04 22:02

I have a div that contains a register wizard, and I need hide/show this div when a button is clicked. How can I do this?

Below I show you t

8条回答
  •  Happy的楠姐
    2020-12-04 22:16

    Use JQuery. You need to set-up a click event on your button which will toggle the visibility of your wizard div.

    $('#btn').click(function() {
        $('#wizard').toggle();
    });
    

    Refer to the JQuery website for more information.

    This can also be done without JQuery. Using only standard JavaScript:

    
    

    Then add onclick="toggle_visibility('id_of_element_to_toggle');" to the button that is used to show and hide the div.

提交回复
热议问题