I am fairly new to wordpress and am trying to define and call a function but cannot get it to work.
The following code appears in a php file that is called from the
I faced the same error like you.
If we use the onclick html attribute, we need to define that onclick function within the same html element (by using tags).
It is best practice to create click event listener using javascript/jquery, than using onclick html attribute.