I wonder what I am doing wrong in this case? I got this button which is an HTML element. When I click on it, I want the function push() to get activated. Unfortunally my console says:
ReferenceError: push is not defined
Can some one help me in this case? Thanks so much!
<button type="button" onclick=push()>Click Me!</button>
<script type="text/javascript">
function push (){.....};
</script>
Use the onclick attribute to execute a script when the element is clicked in HTML.
You can change onclick=push()
to onclick="push()"
to make it work!
Also, there might be something wrong in the body of the push function because of which it is not able to compile - hence, the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With