Calling plugin function inside custom plugin for onclick event

Question

I want testFunction() to call check() that i created in my plugin php when i click My Button. How do i make it work ?

function createButton()
{
    echo '<button onclick="testFunction()">My Button</button>';
}

function check()
{
    alert("Works");
}

function my_php_function()
{
    echo '<script>
    function testFunction() {
      check();
    }
  </script>';
}
add_action( 'wp_footer', 'my_php_function' );
0
, , , , Kitiara 3 years 2020-06-04T20:10:37-05:00 0 Answers 120 views 0

Leave an answer

Browse
Browse