This article shows you how to fix TypeError: $ is not a function on line 1 (or any line) in Oxygen Builder.
Luckily this is a really simple fix, and it's caused by WordPress itself.
Whenever you add any jQuery code to Oxygen (via the JS section of a Code Block), this error will trigger because WordPress does not recognize jQuery well. Despite that issue, it does support jQuery, and it comes pre installed on the CMS. All you need to do is make it easy for WP to understand that you do, infact, want to use jQuery code on you Oxygen Builder Code Blog.
Here’s how to fix it. On a simple chunk of jQuery code, simply swap the $ for jQuery. Here’s an example:
Original: $('.my-paroller').paroller();
Oxygen Builder Compatible: jQuery('.my-paroller').paroller();
For longer jQuery in an Oxygen Builder Code Block that’s toggling the “TypeError: $ is not a function” error, use this:
(function($) {YOUR CODE})( jQuery );
That should solve your problem.
Hi
It works wonderfully, the error message has disappeared.
Many Thanks! you are our hope.
I am very happy there are people like YOU who take the time to help others.
You are an idol..
Glad to help!!
These comments are a big reason why we keep publishing!
Hi James,
please could you explain it to me?
I just have to replace all "$" with "jQuery"? I've been trying for ages to add a position aware button, but unfortunately I can't. maybe you have tips for a good procedure
see here: https://codepen.io/kkick/pen/oWZMov
I also tried changing the background color of the button. However, this negates the javascript effect. maybe you have some tips for me 🙂
Hey, thanks for the solution, but what if i get a "JQuery is not defined" in the code block?