The point is: everything seems to work fine exept for the double click I have to do the first time to show the div.
After the first double click it works fine with one click.
Hi, thanks for you reply.
The problem is that as I click once nothing happens, the second time I click on the same div table hidden div gets visible as I click again it hides and so on. The point is that at first click nothing works. I’m constructing the page but I give you the url so you can have a try and understand what I mean. The URL is www.overthebet.com/overthebet 2018/. As you open the page you can see a list of football matches, make a single click on any match and see what happens at first hit (nothing) and the following click.
If you put the following console.log statement into your function what does it show the first time vs. the second time?
<script type="text/javascript">
function visualizza(idDiv)
{
var DivToShow =idDiv; //Forse è superfluo, nell'if basta indicare idDiv
console.log('DivToShow.style.display = ' + DivToShow.style.display);
if(DivToShow.style.display=='none')
{
DivToShow.style.display='block';
}
else
{
DivToShow.style.display='none';
}
}
You will find, that DivToShow.style.display is a blank string. Try changing your if statement to also look for a blank string and that should solve your problem. The reason it would work the second time, is, after the first click, you function was actually setting the display to none in the else code block. On the second click the display property is ‘none’, so you change it to block and it shows.