I am creating a jquery script to edit some parts of the wordpress page.
This is the code that I have tried so far in functions.php
function theme_name_scripts() {
if (is_page('21')) {
wp_enqueue_script('myscript', get_stylesheet_directory_uri().
'/js/myscript.js', array(), '1.0.0', true);
}
}
add_action('wp_enqueue_scripts', 'theme_name_scripts');
And this is the simple jQuery script that I want to load:
<script type="text/javascript">
var j = jQuery.noConflict();
j(function() {
alert('tables test alert');
});
</script>
The script above is not loading. Please help.
Any help is appreciated.
.jsfile why you use script tags there?<script type="text/javascript">