My Button Default Click Is Not Working In WordPress Using Javascript Code
Anytime you want to use JavaScript in WordPress, you should enqueue it. Save the JS as a file, ie clickbutton.js inside your theme folder: document.getElementById(“defaultOpen”).click(); Then in functions.php, enqueue that file: add_action(‘wp_enqueue_scripts’, ‘wpse_371294_enqueue_js’); function wpse_371294_enqueue_js() { wp_enqueue_script(‘click-button’, get_template_directory_uri() . ‘/clickbutton.js’, array(”), “1.0”, true); } (If you only need the file to run on one page, … Read more