I am working on hide show functionality using JavaScript
but it occurring error on console for onclick function
I am not getting why this error occurring.
JAVASCRIPT CODE
<script type="text/javascript">
function showtabs(id,id1) {
alert(id);
alert(id1);
var e = document.getElementById(id);
var flag = document.getElementById(id1);
if(e.style.display == 'block')
{
e.style.display = 'none';
flag.innerHTML = '+';
}
else
{
e.style.display = 'block';
flag.innerHTML = '-';
}
}
PHP CODE
<?php
$output.='<div class="span6">
<div class="header" onclick="showtabs(my_section,icon);">
<h1>My Section <span class="iconc" id="icon">+</span></h1>
</div></div>';
$output.='<div id="my_section" style="display:none;">This is my section</div>';
echo $output;
?>
Error Log
TypeError: e is null
if(e.style.display == 'block')
my_section