The code seems fine. Please check by loading the script in the footer and also use the wp_footer in your .php file.
Related Posts:
- Creating Ajax backend for Specialised Page Template? Should admin-ajax.php be used?
- jQuery Ajax() doesn’t work when the page is accessed as a WordPress template page
- Is it safe to include a javascript file in a template’s php file?
- php ajax problem – weird 301 responses!
- Insertng HTML and jQuery into a page that uses the Defaut template
- JQuery load php – php file without the template
- JQuery multiple toggle values
- TypeError: $ is not a function Error using parallax effect in WordPress Template [duplicate]
- jQuery Add/Remove Classes Not Working
- jQuery equivalent of JavaScript’s addEventListener method
- What is content-type and datatype in an AJAX request?
- How to send multiple data fields via Ajax?
- When and why to ‘return false’ in JavaScript?
- Download File Using jQuery
- Jquery Ajax Posting JSON to webservice
- How is JavaScript .on() method defined?
- correct way of comparing string jquery operator =
- Jquery to change form action
- Split string in jquery
- How can I expand and collapse a using javascript?
- Detecting value change of input[type=text] in jQuery
- Javascript : array.length returns undefined
- Comparing dates in jquery
- Slide right to left?
- How do I send this form's output to a new WordPress page?
- Annoying “JQMIGRATE: Migrate is…” in console after update to WordPress 4.5
- Update jquery version
- Correct Method to run scripts with dependencies without enqueue?
- How to prevent wordpress from loading old versions of jquery in wp_head();?
- WP set auth cookie using Ajax is not saved to browser
- Modify Custom Field in Media Library using JavaScript
- Loading jQuery With Two Fallbacks
- Moving jQuery to the footer without using de-register in WordPress
- Including jQuery in WordPress
- Comment form vaildation
- Enqueuing jQuery in plug-ins
- Prevent five different copies of jquery from being included on every page
- Script doesn’t load because of a javascript MIME type error
- javascript is not working on Event Submission?
- TinyMCE – TypeError: r is undefined
- Auto-detect javascript errors and warn theme user
- combining js scripts from a js newb [closed]
- Heartbeat API: How to access data already enqueued?
- How to get a value from PHP in Jquery through Ajax
- How to stop focus() in custom js from scrolling to footer?
- Getting post meta in the flex slider
- Removing jQuery from footer
- Use jQuery to conditionally hide elements in Quick Edit
- AJAX Loaded Glossary like Search results with links to other entries from custom table
- WordPress jquery files not being enqueued
- jQuery code not working in widgets page
- Load random posts without refreshing page (jQuery)?
- How to use jquery included with wordpress for jpanelmenu
- Cannot get Jquery to work with wordpress
- Problem getting .js file to load via a plugin
- Using jquery-1.7.2.min.js instead of the wordpress jquery
- WordPress error when replacing local jQuery by externally-hosted
- Adding jQuery UI elements to WordPress page
- Create special WordPress slideshow with “jquery.cycle.all.js”
- Jquery UI Google CSS, from where?
- datepicker for custom post type admin
- Disable Cloudflare Rocket Loader for jQuery javascript and make it load first
- How to add plugin with jQuery to custom theme?
- Manipulate retrieved ajax data in php
- Disable auto hide of the login form on Woocommerce’s checkout page
- WordPress Front-End Theme Editor
- Sorting dynamic table content with jQuery
- jQuery .load and WP function
- WordPress 3.2.1: jQuery is not defined, breaks Admin panel
- inner anchor scrolling with wordpress
- Bootstrap and jQuery error: $ is not defined
- Fire action after enqueue script
- Auto next upon clicking image without clicking Next button
- Doing Math with Gravity Forms List
- How can I get this menu container to be the height of the contents?
- JQuery is not working after complete load of the page
- Remove button from page if viewed through Customizer
- Add a jQuery snippet for sepcific user role
- JQuery and Javascript to pan image
- How to add JS snippet before closing tag?
- Show/Hide text after the first paragraph
- How to specify url for ajax call in wordpress plugin
- Dynamic image grid gallery
- Check with jQuery value of checkbox from custom admin panel
- JS script not being included [closed]
- WooCommerce – PrettyPhoto appending URL with #prettyPhoto
- Are you sure popup on Contact Form 7 [closed]
- change the icon of a custom post type in WordPress to use twitter boostrap
- Using jQuery toggle() in WordPress post to show/hide Tweet button?
- Call a Simple JQuery from within Flash
- Ajax request with jQuery without WP_ajax
- Change image on post title hover (more than one instance) – Jquery
- How to fire jQuery after $(window).on(‘load’)
- JQuery WordPress gallery [closed]
- JS file not loading [closed]
- How can insert JQuery in WordPress? [closed]
- Jquery in IE, fully messed up
- Theme variation conflict with jquery select2 dropdown
- jQuery datepicker not showing on admin menu
- Can’t seem to check off a category checkbox with jquery?