Answer the question
In order to leave comments, you need to log in
Why does the function only work on the second click?
Why does the function only work on the second click? With one click, nothing happens. This happens when you reload the page.
function openbox(id){
display = document.getElementById(id).style.display;
if(display=='none'){
document.getElementById(id).style.display='block';
}else{
document.getElementById(id).style.display='none';
}
}
<div class="ac" onclick="openbox('box'); return false"><?php profile_picture_show(); ?></div>
Answer the question
In order to leave comments, you need to log in
Because you're reading the value through style.display and it's coming from the style attribute. For the first time, nothing was written in it. You here - https://learn.javascript.ru/styles-and-classes#th...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question