custom button inside admin menu

[ad_1]

Hello friends,

so i have a small plugin where i am creating an admin menu and then directing to another php file that is being shown when i press on the item. inside the php i created a button but i do not know how to make the button do something when being clicked. i tried so much js seems not to be working:

add_action(‘admin_menu’, ‘my_admin_menu’);

function my_admin_menu() {
add_menu_page(
‘MyPlugin’,
‘MyPlugin’,
‘manage_options’,
plugin_dir_path(FILE) . ‘view.php’,
null,
‘dashicons-saved’,
15
);
}

function wptuts_scripts_basic()
{
// Register the script like this for a theme:
wp_register_script( ‘custom-script’, plugin_dir_path(FILE) . ‘app.js’ );
wp_enqueue_script( ‘custom-script’ );
}

add_action( ‘wp_enqueue_scripts’, ‘wptuts_scripts_basic’ );

——————————-

app.js :

document.getElementById(“test”).addEventListener(“click”, function () {
console.log(“hello”);
})

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer