Cannot get the html part working with javascript in functions.php child theme
-
Hi, I cannot seem to get my code output to display on the wordpress page.
I am trying to put this simple pop up box to display, and then a greeting when client clicks on it.
I have put the following code in functions.php file:<?php function childtheme_parent_styles() { wp_enqueue_style( 'parent', get_template_directory_uri().'css/style.css' ); function mytheme_files() { wp_enqueue_style('mytheme_main_style', get_stylesheet_uri()); } add_action( 'wp_enqueue_scripts', 'childtheme_parent_styles'); wp_register_script('twentythirteen',get_stylesheet_directory_url().'/js/custom.js'); add_action( 'wp_enqueue_scripts', 'twentythirteen_enqueue_scripts' ); add_action( 'wp_footer', mytheme_add_button_html' ); } function mytheme_enqueue_scripts() { if( is_page(18) ) { wp_enqueue_script( 'twentythirteen', get_stylesheet_directory_uri() . "/js/custom.js', array{ '( ). '1.0.0' , false ); function mytheme_add_scripts() {?> <div id="button-container"> '<input type="button" onclick="Alert">'Click here!'?></button></div>' }My javascript code is in a file called custom.js in the js folder:
<SCRIPT LANGUAGE="Javascript"> var greet = "Hooray!"; document.write(greet); </script>
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
The topic ‘Cannot get the html part working with javascript in functions.php child theme’ is closed to new replies.