別の関数を使用して関数を無効にする方法を知りました。追加コースを求めるフォームがありますが、ユーザーが余分な作業を完了していない場合は、入力が隠されています。私は彼らが入力のセットを削除し、彼らの心を変えた場合に備えて、フェイルセーフに入れたいと思います。別の関数で関数を無効にする - バニラJS
私が助けが必要なのは、機能1が発生したかどうかをチェックするフェールセーフ機能を作成することです。
CodePen:http://codepen.io/theodore_steiner/pen/ORzpQQ
function hideCourseWork() {
var otherEducationHistory = document.getElementById("otherEducationHistory");
otherEducationHistory.style.display = "none";
if (otherEducationHistory.style.display == "none") {
var noAdditionalCourseWork = document.getElementById("noAdditionalCourseWork");
var checkNo = document.getElementById("checkNo");
var undo = document.getElementById("undoNoAdditionalCourseWork");
noAdditionalCourseWork.style.top = "-48px";
checkNo.style.top = "-65px";
undo.style.top = "-65px";
undo.style.top = "-63px";
}
};
<div class="input-group" id="other-education">
<p class="subtitleDirection">Please list in chronological order, any additional cources beyond the degree(s) listed above, including any Ministry of Education Courses. If you have not completed any additional course work, please indicate.</p>
<div class="clearFix"></div>
<label id="otherEducation">Additional Courses*</label>
<div id="otherEducationHistory">
<input type="text" class="three-lines" name="otherUniversity_1" placeholder="Institution" onblur="this.placeholder='Institution'" onfocus="this.placeholder=''" />
<input type="text" class="three-lines" name="otherDegree_1" placeholder="Degree/Diploma" onblur="this.placeholder='Degree/Diploma'" />
<input type="date" class="three-lines" name="otherEducationYear_1" />
<input type="button" value="+" onclick=addOtherEducation() />
</div>
<!--end of otherEducationHistory div-->
<div class="clearFix"></div>
</div>
<!--end of other-education div-->
<p id="noAdditionalCourseWork">I have not completed any additional course work.</p>
<input type="radio" name="checkNo" id="checkNo" onclick="hideCourseWork()" />
<br />
<p id="undoNoAdditionalCourseWork" onclick="reAddCourseWork()">(Undo).</p>
イムは本当に問題がここに混乱して何?私たちは、無線の価値に基づいてHTML要素を隠して表示するだけではありませんか? –
はい。しかし、私はそれをさらに一歩踏み出し、機能を介して私がそれをやり遂げる方法を学びたいと思っていました...この例だけでなく、将来の知識のために。 –
なぜ、オーバーエンジニアリングなのでしょうか?私は私のキャリアの中で決して機能を「無効に」しなければならなかった –