Jak dodać wydarzenie OnClick w JavaScript
var element = document.getElementById("elem");
element.onclick = function(event) {
console.log(event);
}
TC5550
var element = document.getElementById("elem");
element.onclick = function(event) {
console.log(event);
}
<script>
function myFunction() {
alert("ALERT");
}
</script>
<button onclick="myFunction">Click</button>
<script>
function myFunction() {
alert("ALERT THIS FUNCTION HAS RUNNED");
}
</script>
<button onclick="myFunction">click to run function</button>
document.getElementById("Save").onclick = function ()
{
alert("hello");
//validation code to see State field is mandatory.
}