Here is something that I've used for ages now and all of the sudden I get these strange behaviours, maybe someone knows the reason why? Here is my HTML:
<div class="tooltip" id="tooltip"></div>
<input type="button" name="hide" value="hide" onclick="hide('tooltip');" />
<input type="button" name="show" value="show" onclick="show('tooltip');" />
Here is the JavaScript below the HTML code:
<script type="text/javascript">
function hide(id)
{
document.getElementById(id).style.display = 'none';
}
function show(id)
{
document.getElementById(id).style.display = '';
}
</script>
Now there shouldn't be anything wrong with this code. It should hide or show tooltip on each button click. Now the weird thing going on is when I click on the hide button it hides itself, and when I click on show nothing happens. Hide is still hidden.
Did anyone have similar problem? Is there a work-around for it? Maybe another approach for accomplishing the same thing (pure JavaScript)?
UPDATE: Changed it to block, still isn't working. I mean why would it hide the button I'm clicking on when there is no connection to that whatsoever? I'm using latest Firefox by the way. And I added alert in the function same thing. Here is re-written code:
function hide(id)
{
alert(id);
document.getElementById(id).style.display = 'none';
}
function show(id)
{
alert(id);
document.getElementById(id).style.display = 'block';
}