如果满足条件,我有一个函数应该在 P 元素中显示一条消息。该功能运行良好,但是当您按下按钮时,发送到“output1”的文本会短暂出现,然后消失。我曾尝试将 JS 放在头部和身体中,但似乎没有什么不同。有任何想法吗?谢谢。
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>