• Resolved doublees

    (@doublees)


    I am using ocean wp theme. When I build a custom Html block in elementor and publish it, it seems that jquery is not defined. neither defining a jquery CDN in the html elemetonr block works nor in custom js panel. it always errors $ is not a function. how can I fix it?
    it is interesting that in the Html block when I am in the panel and writing the code I do not get such an error and the code works properly. but when I publish it, it will error and js part will not work. HELP PLEASE:)

    • This topic was modified 4 years, 11 months ago by doublees.
    • This topic was modified 4 years, 11 months ago by doublees.
    • This topic was modified 4 years, 11 months ago by doublees.
    • This topic was modified 4 years, 11 months ago by doublees.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    Sorry about your error. The ‘$’ symbol is used by different libraries for different functions. by default, it’s disabled in order to avoid conflict with other scripts that use $. but in your case, there seems to be no other function using ‘$’. You can fix the issue by adding the following snippet:

         $ = jQuery.noConflict(true);
          //Add your javascript here
    

    Add the jQuery noConflict function just above your javascript and it should work.

    You can also refer to this thread on Stack Overflow about jQuery noConflict

    Edit: In case another script is installed that uses the dollar sign in a different way below is a safer solution:

    
    jQuery(document).ready(function( $ ) {
    	
    	// $ Works! You can add your code in here
    	// console.log($);
    	
    });
    

    you can wrap your code in the function above and you’ll be able to use the ‘$’ you can read more on digwp.com

    Thread Starter doublees

    (@doublees)

    Thank you very much for your support it works

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘oceanwp Problem. jquery ” $ is not a function”’ is closed to new replies.