how to toggle (hide/show) a table onClick of tag in java script

前端 未结 8 2083
青春惊慌失措
青春惊慌失措 2021-02-05 13:24

I want to show and hide (toggle) the

onClick event of the . this is my tag

&         


        
      
      
      
8条回答
  •  执笔经年
    2021-02-05 13:45

    You need to modify your function as:

    function toggleTable()
    {
       if (document.getElementById("loginTable").style.display == "table" ) {
           document.getElementById("loginTable").style.display="none";
    
       } else {
          document.getElementById("loginTable").style.display="table";
    
    }
    

    currently it is checking based on the boolean parameter, you don't have to pass the parameter with your function.

    You need to modify your anchor tag as:

    Login
    

提交回复
热议问题