문제

This is what I have and it's not working.

document.getElementById('form1').addEventListener('submit', function(){
    document.getElementById('donate').style.display = 'none';
    document.getElementById('topMessage').style.display = 'none';
});

The javascript console shows this error:

Uncaught TypeError: Cannot set property 'onclick' of undefined

Any suggestion is much appreciated.

도움이 되었습니까?

해결책

Okay, I figured it out. All I need the preventDefault(); So, here's the solution.

document.getElementById('form1').addEventListener('submit', function(evt){
    evt.preventDefault();
    document.getElementById('donate').style.display = 'none';
    document.getElementById('topMessage').style.display = 'none';
})
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top