我有一個函數,如果條件滿足,我應該在P元素中顯示消息。該函數運行正常,但當您按下按鈕然後消失時,發送到'output1'的文本會短暫出現。我曾嘗試將JS放在頭部和身體中,但它似乎沒有什麼區別。有任何想法嗎?謝謝。由innerHTML修改的文本不會保持可見
HTML:
<p id="output1"><p>
的Javascript:
<script>
function logicProcess() {
// alert('function launched');
if(document.getElementById('q1Y').checked || document.getElementById('q2Y').checked || document.getElementById('q3Y').checked) {
document.getElementById("output1").innerHTML = "Sorry, you don't qualify for our shared ownership properties";
}
else {
document.getElementById("output1").innerHTML = "You may qualify for our shared ownership scheme. Please complete the registration form.";
}
}
</script>
按鈕是否也提交表單(或執行其他導航)? – nnnnnn 2013-05-07 11:06:37
兩個字:防止默認 – Brainfeeder 2013-05-07 11:07:17