0

I wrote a simple jquery function that loads on document ready. It should detect user agent. My site is a WordPress site. My script works in a standard HTML page but not in WordPress. Any ideas?

5
  • possible duplicate of How do I add a simple jQuery script to WordPress? Commented Mar 4, 2015 at 20:04
  • what does doesn't work mean? Does script get loaded? Does it throw errors? Not much detail here to work from Commented Mar 4, 2015 at 20:07
  • It loads. Simple alert fires to notify me. Console reports no errors. Commented Mar 4, 2015 at 20:44
  • Can you show us your jQuery? So that we may see where the error may be Commented Mar 4, 2015 at 20:46
  • use this document ready: jQuery(document).ready(function($){--your script--}); Commented Mar 5, 2015 at 8:07

1 Answer 1

1

Turns out you had to replace the usual $() to jquery() in WordPress.

Sign up to request clarification or add additional context in comments.

1 Comment

That's right. Wordpress uses jQuery in 'no-conflict' mode in case another of your Javascript libraries also uses the $ symbol. See here: learn.jquery.com/using-jquery-core/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.