Show/hide forms using buttons and JavaScript

前端 未结 5 452
鱼传尺愫
鱼传尺愫 2020-12-03 15:34

I need to show a form using a button, and hide it when the user presses another button, because the other button shows another form. I did a similar thing with a select box,

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 16:21

    There's the global attribute called hidden. But I'm green to all this and maybe there was a reason it wasn't mentioned yet?

    var someCondition = true;
    
    if (someCondition == true){
        document.getElementById('hidden div').hidden = false;
    }

    https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/hidden

提交回复
热议问题