0

If, if else and else onclick

I need help with onclick for example html <button Id="yes">click me</button> <script> var yes = document.getElementById("yes"); if (yes.clicked == true) { promt("name"); } </script>

3rd Dec 2016, 8:38 PM
Juan Madrigal
Juan Madrigal - avatar
3 ответов
+ 1
yes.addEventListener("click", function(e) { prompt("name"); }, false);
3rd Dec 2016, 8:58 PM
Ondřej Doněk
Ondřej Doněk - avatar
+ 1
Replace your script with this: document.addEventListener("DOMContentLoaded", function() { var yes = document.getElementById("yes"); yes.addEventListener("click", function() { prompt("test"); }, false); }, false);
3rd Dec 2016, 9:42 PM
Ondřej Doněk
Ondřej Doněk - avatar
0
yesyes
23rd Oct 2018, 4:02 AM
Lilisharyati