Title: Code doesn&#8217;t work
Last modified: December 26, 2019

---

# Code doesn’t work

 *  Resolved [paul8998](https://wordpress.org/support/users/paul8998/)
 * (@paul8998)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/code-doesnt-work-5/)
 * Dear Customer Support,
 * We use HFCM plugin and it works well. But there is an issue with Javascript code.
   If I write a simple code it works fine, but if I try to write a code with selectors(
   like query selector or get element by ID) in some cases the code doesn’t work
   even though it was checked in the console. How is it possible to solve the issue?
 * Thank you.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcode-doesnt-work-5%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [99robots](https://wordpress.org/support/users/99robots/)
 * (@99robots)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/code-doesnt-work-5/#post-12270934)
 * Hi [@paul8998](https://wordpress.org/support/users/paul8998/) – Thank you for
   contacting us. We think the issue is in your JavaScript code. To be specific,
   we think your selected id/class/tag on querySelector must be loaded before your
   JavaScript code executes.
 * Here’s a possible solution to your problem:
    1. Make sure location of your code
   selected as footer. 2. a. If you are running JQuery put your code inside following
   function. Also make sure JQuery library is loaded before your custom code loads.
 *     ```
       $( document ).ready(function() {
           // Your code goes here..
       });
       ```
   
 * Or
 * 2. b. If you are running vanilla JavaScript then use the following function.
 *     ```
       document.addEventListener("DOMContentLoaded", function() {
         // Your code goes here..
       });
       ```
   
 * Please let us know if you need anything else.
 * Thanks
 *  Plugin Support [DraftPress Support Team](https://wordpress.org/support/users/99robotsteam/)
 * (@99robotsteam)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/code-doesnt-work-5/#post-12329259)
 * We have not received a reply from you for over a couple of weeks, therefore we
   will be closing this ticket. Please create a new one if you require any additional
   help.
 * Thank You,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Code doesn’t work’ is closed to new replies.

 * ![](https://ps.w.org/header-footer-code-manager/assets/icon-256x256.png?rev=2681303)
 * [Header Footer Code Manager](https://wordpress.org/plugins/header-footer-code-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/header-footer-code-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/header-footer-code-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/header-footer-code-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/header-footer-code-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/header-footer-code-manager/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [DraftPress Support Team](https://wordpress.org/support/users/99robotsteam/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/code-doesnt-work-5/#post-12329259)
 * Status: resolved