I want to show and hide (toggle) the <table>
onClick
event of the <a>
.
this is my <a>
tag
<a id="loginLink" onclick="toggleTable(true);" href="#">Login</a>
Here is my Javascript function toggleTable(hide)
:
<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);
}
}
</script>
and here is my <table>
tag:
<table id="loginTable" border="1" align="center" style="display:none">
The first time when I click the <a> link
it shows my table, but not hiding back when I click it next time. What am I doing wrong?