Zagreb completely. I don't understand why the modal window is called on load, then how should this happen on click?
-
<body> <button id="btmCheckEmpty">Проверить</button> <script contenteditable> window.onload = function() { document.getElementById("btmCheckEmpty").onclick = alert('кнопка нажата'); } </script> </body>
JavaScript Anonymous, Nov 13, 2020 -
Instead of assigning a function, you call it.
function showAlert () {
alert('кнопка нажата');
}
window.onload = function() {
document.getElementById("btmCheckEmpty").onclick = showAlert;
}Anonymous -
Or like this:
<body>
<button id="btmCheckEmpty">Проверить</button>
<script contenteditable>
window.onload = function() {
document.getElementById("btmCheckEmpty").addEventListener('click',function(){alert('кнопка нажата');});
}
</script>
</body>Anonymous
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!