You don’t seem to have a trigger for your JS. You can test that the script is actually running by adding a quick console, such as
console.log('xyz.js is running');
Once you’re sure your JS is running, you can add a trigger. If you’re already loading jQuery, it has an easy .ready()
function to use, but if not, there are other ways.
It’s also best practice to enqueue your JavaScript, instead of adding <script>
tags directly. See wp_enqueue_script(). You may want to do this before adding your console and before adding the trigger, as really enqueueing is the first step.
Related Posts:
- What is TypeScript and why would I use it in place of JavaScript? [closed]
- How to do associative array/hashing in JavaScript
- map function for objects (instead of arrays)
- Check if a string has a certain piece of text [duplicate]
- How to play audio?
- How to write a countdown timer in JavaScript?
- TypeScript foreach return [duplicate]
- “document.getElementByClass is not a function”
- how to render a react component using ReactDOM Render
- What does “javascript:void(0)” mean?
- What does this symbol mean in JavaScript?
- Go back button in a page
- ‘react-scripts’ is not recognized as an internal or external command
- After $npm install, Getting Error: Cannot find module ‘../lib/utils/unsupported.js’
- What’s the best way to convert a number to a string in JavaScript?
- React Native: this.setState is not a function
- How to perform string interpolation in TypeScript?
- Angular ForEach in Angular4/Typescript?
- Timers in React Native (this.setTimeout)
- CSS height 100% percent not working
- Angular 4 setting selected option in Dropdown
- How can I upload files asynchronously with jQuery?
- How do I format date in jQuery datetimepicker?
- XMLHttpRequest module not defined/found
- Cannot read property ‘bind’ of undefined. React.js
- Why is my asynchronous function returning Promise {
} instead of a value? - NodeJs : TypeError: require(…) is not a function
- How can I convert an image into Base64 string using JavaScript?
- Javascript checkbox onChange
- Number prime test in JavaScript
- document.getElementById not working / Display
- jQuery: Check if div with certain class name exists
- What does ngf-select do and why is it needed for form validation?
- What is jQuery Unobtrusive Validation?
- CreateElement with id?
- Print PDF directly from JavaScript
- Set value of hidden input with jquery
- How does AJAX work?
- NPM install fails with node-gyp
- element.setAttribute is not a function
- gapi is not defined – Google sign in issue with gapi.auth2.init
- Remove all special characters with RegExp
- jQuery: Get selected element tag name
- Does ECMAScript 6 have a convention for abstract classes?
- Why is jquery show() not working in example
- console.log showing contents of array object
- TypeError: $ is not a function WordPress
- Fully responsive HTML5 video
- Make Discord bot send picture with message with NodeJS
- RegEx for Javascript to allow only alphanumeric
- How to check for an undefined or null variable in JavaScript?
- HTML anchor link – href and onclick both?
- How to use forEach loop correctly in angular 2?
- javascript push multidimensional array
- How can I know which radio button is selected via jQuery?
- jquery toggleClass not working
- Positioning element at center of screen
- Can WordPress be made to support websockets?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- Remove extra Google Maps script
- trying to enqueue script in wordpress
- single page wordpress
- initial open/toggle PluginDocumentSettingPanel panel in document setting block editor gutenberg
- Headless WordPress: How to authenticate front end requests?
- Theme Customiser not live previewing changes on pseudo elements
- Instantiate TinyMCE via JS ( rather than PHP/wp_editor )
- Restrict file types in the uploader of a wp.media frame
- How can I get the standard WP-Editor through Javascript?
- Can I change an external script’s HTML?
- How to transform a legacy widget into a block
- Gutenberg select categories
- const { __ } not working in IE11
- Modal working only on home page
- AJAX not Working with php as supposed
- how to localized scripts of new page requested by ajax?
- Performance vs plugin genrated javascript
- Cannot use characters ” in jQuery script in WordPress
- Why is JavaScript being added to header as application/oembed?
- How to install cool javascript feature in WordPress?
- How can I load certain JavaScripts only on blog pages?
- jQuery UI Tools (Flowplayer) Issues
- Javascript for a specific wordpress page
- How can I leverage browser cache for minified JS or minified CS files?
- Close modal window after form submit [closed]
- Form will not popup, when clicking on the link to the form
- internal anchor links no longer working after upgrade
- Generating dynamically Schema LD+JSON microdata with Javascript works in test environment but not in WP
- How do you change the text “Update failed. You are probably offline.”
- on change form submit variable value not updating
- How do I make a savable preview like Youtube Gutenberg block?
- iFrame onLoad in custom Gutenberg block
- The page isn’t redirecting properly was given when redirecting
- How To Pull Information From A Page And Input The Data In The WordPress User Database Table
- How to register or enqueue script and stop it being called in head?
- I keep getting Javascript error messages
- convertEntities() used before it is defined
- Orbit Slider and Events Manager Plug-in JavaScript
- Where to include JS library in gutenberg blocks
- How to securely set dynamic HTML content with JavaScript?
- Astra Mobile Cart Drawer is blank on home page