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

avaidoMaing

New Member
I want to show and hide (toggle) the \[code\]<table>\[/code\] \[code\]onClick\[/code\] event of the \[code\]<a>\[/code\].this is my \[code\]<a>\[/code\] tag\[code\]<a id="loginLink" onclick="toggleTable(true);" href="http://stackoverflow.com/questions/15698542/#">Login</a>\[/code\]here is my java script function \[code\]toggleTable(hide)\[/code\] \[code\]<script>function toggleTable(hide){if (hide) {document.getElementById("loginTable").style.display="table";document.getElementById("loginLink").onclick = toggleTable(false);} else {document.getElementById("loginTable").style.display="none";document.getElementById("loginLink").onclick = toggleTable(true);}\[/code\]} and here is my \[code\]<table>\[/code\] tag\[code\]<table id="loginTable" border="1" align="center" style="display:none">\[/code\]1st time when I click the \[code\]<a> link\[/code\] it shows my table, but not hiding back when i click it next time. what i m doing wrong.thanks
 
Back
Top