Title: Javascript won&#8217;t trigger
Last modified: January 27, 2025

---

# Javascript won’t trigger

 *  Resolved [revixi5](https://wordpress.org/support/users/revixi5/)
 * (@revixi5)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/javascript-wont-trigger/)
 * Do you know why my javacript doesn’t trigger when i add it to the header of my
   page? It appear normaly in the source code and work in a local environment (or
   in a html environement), by in my server with WordPress it’s block by something.
   Thanks for your help.
 *     ```wp-block-code
       <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script><script type="text/javascript">$(document).ready(function(){$('#click').click(function(){window.location.href = 'https://MyURL.com';});setTimeout(function(){$('#click').trigger('click');}, 2000);});</script>
       ```
   

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

 *  Plugin Support [DraftPress Support Team](https://wordpress.org/support/users/99robotsteam/)
 * (@99robotsteam)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/javascript-wont-trigger/#post-18269794)
 * Hi [@revixi5](https://wordpress.org/support/users/revixi5/),
 * We just tested your script on a demo WordPress site, and it worked as expected(
   redirecting after 2 seconds or when clicking an element with `id="click"`). This
   suggests the code itself is valid, but WordPress-specific factors might be interfering
   on your end. Common WordPress-specific issues include:
    1. **jQuery Conflict**: WordPress uses `jQuery` instead of `$`. Update your code
       to:
       `javascript jQuery(document).ready(function($) { // Your code here });`
    2. **Missing Element**: Ensure a `#click` element exists (e.g., `<button id="click"
       >Redirect</button>`).
    3. **Plugin/Theme Conflicts**: Deactivate plugins temporarily or switch themes 
       to test for conflicts.
    4. **Caching/Script Order**: Clear caches and ensure jQuery loads before your script.
 * We recommend sharing these points with your developer for targeted troubleshooting.
   If issues persist, provide a page link and browser console errors.
    -  This reply was modified 1 year, 4 months ago by [DraftPress Support Team](https://wordpress.org/support/users/99robotsteam/).
 *  Thread Starter [revixi5](https://wordpress.org/support/users/revixi5/)
 * (@revixi5)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/javascript-wont-trigger/#post-18270335)
 * Oh my God! Thanks a lot for your help. It’s working perfectly now.
 *  Plugin Support [DraftPress Support Team](https://wordpress.org/support/users/99robotsteam/)
 * (@99robotsteam)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/javascript-wont-trigger/#post-18272331)
 * Hi [@revixi5](https://wordpress.org/support/users/revixi5/) ,
 * We’re glad we could help.
 * If you’re enjoying our plugin, we’d really appreciate it if you could take a 
   moment to leave us a review. Your feedback helps us improve and lets others know
   about your experience.

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

The topic ‘Javascript won’t trigger’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [DraftPress Support Team](https://wordpress.org/support/users/99robotsteam/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/javascript-wont-trigger/#post-18272331)
 * Status: resolved