Combine 3 functions into one in javascript

后端 未结 2 466
心在旅途
心在旅途 2021-01-29 13:43

I tried to combine these 3 functions into one, but after I did that, it won`t work. can you help me combine those?

function showForm(id, name) {         


        
2条回答
  •  花落未央
    2021-01-29 13:48

    Try This :

    function showForm (id, name)  { 
        document.getElementById('submitForm').style.display = "block";
        if (id == 0) 
            document.getElementById('submitForm').style.display = "none";
         else 
            document.getElementById(i).style.display = 'block';
        }
    

    JavaScript statements can be grouped together in code blocks, inside curly brackets {...}.

提交回复
热议问题