Не могу понять, почему событие onclick запускается при запуске файла, когда он должен быть вызван, когда я нажимаю на div.событие onclick вызывается при загрузке страницы
КОД:
<html>
<head>
<link rel="Stylesheet" type="text/css" href="shoppingcart.css">
</head>
<script type="text/javascript">
var count=0;
function swap()//cannot understand why it is running on loading the page
{
if(count==0)
{
document.getElementById('log').style.display='none';
count++;
}
else
{
document.getElementById('log').style.display='block';
count=0;
}
}
</script>
<body>
<div onclick="swap()" style="padding-left:30px;height:100px;width:300px;float:left;margin-right:180px" >
<h1 style="center">LOG IN</h1>
</div>
<div id="log" class="block border goudystout">
Email:<input type="email"/>
Password:<input type="password"/>
</div>
</body>
</html>
Нам нужно увидеть больше кода. – HaukurHaf
class = "block border goudystout", возможно, вы установили ** блок ** класс отображения: блок **! Important **; поэтому он не работает. – Nabi