I have an HTML site, that I need to implement into Wordpress.
Now I have problems to get the functions to start.
I have the Avada theme activated and paste the inline js code with the "code block" element into the site. The inline js is wrapped into $(document).ready(function () { });
and calling an object with object = new Object(options, options);
. Until here everything works fine, but then I get an error in the additionally js file.
The structure in the additionally file is as follows:
class 1 {
}
class 2 {
}
class Object {
constructor {}
function {}
function {}
and so on
}
And in that file I'm getting an Uncaught TypeError: Cannot read property 'extend' of undefined
.
This is the row:
this.options = $.extend({}, defaultOptions, options);
I'm pretty sure it's because of the jQuery.
The file is added with the following function
wp_register_script('custom-script', get_stylesheet_directory_uri() . '/script.js', array('jquery'), '1.11.2', true);
I don't know if it's better to wrap everything with jQuery and how to do it or to replace the jQuery things with plain javascript?