Uncaught ReferenceError: contactchoice is not defined at HTMLInputElement.onclick
Hello,
Je me lance dans le js et pour mon 1er script, j'ai tenté de faire un truc simple :
J'ai deux div "contact" et "contact-choice", par défaut, c'est la première qui est affichée. Au clic sur un bouton, je voudrais afficher la deuxième (et vice versa).
Sous code-pen (https://codepen.io/waf-alors/pen/ebrddZ) , j'ai fais un truc qui fonctionne bien, mais lorsque je l'intègre sur mon site, ça ne fonctionne plus :
Uncaught ReferenceError: contactchoice is not defined at HTMLInputElement.onclick
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| document.getElementById("contact").addEventListener("click", function contact() {
document.getElementById('contact').style.display = 'block';
document.getElementById('contact-choice').style.display = 'none';
console.log('contact');
});
document.getElementById("contactchoice").addEventListener("click", function contactchoice () {
document.getElementById('contact-choice').style.display = 'block';
document.getElementById('contact').style.display = 'none';
console.log('contact');
}); |
Je récupère bien les id, mais visiblement, il ne trouve pas les fonctions. D'où vient le problème ?