Use the 'event' object in the the 'onclick' function
e.g
Sample code and demo is here
Demo
e.g
<button onclick="myFunction(event,this)">Click me</button>
<script>output:
function myFunction(e, element) {
console.log("event=", e, "element=", element);
}
</script>
Sample code and demo is here
Demo
No comments:
Post a Comment