1
私のJSには少し問題があります。私は自分のサイトに「どのように働いていますか」というテンプレートを持っています。このテンプレートは、開始されると、自分のウェブサイトをどのように使うのが最適なのかを判断します。私のDivsのOnclick呼び出し関数が動作しません
私のコードは'showHelp()'
と'next()'
の機能では問題なく動作しますが、'close()'
の機能では機能しません。それが動作していない理由は、JS
function showHelp() {
document.getElementById('howItWorksBackground').style.display = "block";
document.getElementById('howItWorks1').style.display = "block";
}
function next() {
document.getElementById('howItWorks1').style.display = "none";
document.getElementById('howItWorks2').style.display = "block";
}
function close() {
document.getElementById('howItWorksBackground').style.display = "none";
}
<button id="howItWorks" onclick='showHelp()'>How it works?</button> //This button initiates it
<div id="howItWorksBackground" style="display: none;"> //This <div> is changed to "display: block" with the JS below
<div id="howItWorks1" style="display: none;">
<p id="text"> Some text...</p>
<button id="next" onclick='next()'>Next</button>//upon clicking this, howItWorks2
is displayed and this block gets hidden
<div id="whiteSpace"></div>
</div>
<div id="howItWorks2" style="display: none;">
<p id="text">Some text.....</p>
<button id="next" onclick='close()'>Close</button> \t //And when clicking here, the entire
"howItWorksBckground" should be hidden again, but my JS doesn't call it
<div id="whiteSpace">
<div id="insideText">
Some text...
<br>
Some text...
</div>
</div>
</div>
</div>
は本当に基本的なものですが、私は把握することはできません、...すべてのヘルプは大歓迎します!
'closeIt'またはそのような何かにあなたの関数の名前を変更します。 (window.closeはすでに存在しています) –