ReferenceError: jQuery is not defined at
-
I got error in this line:
jQuery(document).ready(function() { document.querySelectorAll(".ez-toc-section").forEach(t=>{ t.setAttribute("ez-toc-data-id", "#" + decodeURI(t.getAttribute("id"))) } ), jQuery("a.ez-toc-link").click(function() { let t = jQuery(this).attr("href") , e = jQuery("#wpadminbar") , i = 0; 30 > 30 && (i = 30), e.length && (i += e.height()), jQuery('[ez-toc-data-id="' + decodeURI(t) + '"]').length > 0 && (i = jQuery('[ez-toc-data-id="' + decodeURI(t) + '"]').offset().top - i), jQuery("html, body").animate({ scrollTop: i }, 500) }) });
ReferenceError: jQuery is not defined
I know this happen maybe because minify js using autoptimize.
I’ve open the ETOC plugin folder and find this code:
private static function inlineScrollEnqueueScripts() { $offset = wp_is_mobile() ? ezTOC_Option::get( 'mobile_smooth_scroll_offset', 0 ) : ezTOC_Option::get( 'smooth_scroll_offset', 30 ); $inlineScrollJS = <<<INLINESCROLLJS jQuery(document).ready(function(){document.querySelectorAll(".ez-toc-section").forEach(t=>{t.setAttribute("ez-toc-data-id","#"+decodeURI(t.getAttribute("id")))}),jQuery("a.ez-toc-link").click(function(){let t=jQuery(this).attr("href"),e=jQuery("#wpadminbar"),i=0;$offset>30&&(i=$offset),e.length&&(i+=e.height()),jQuery('[ez-toc-data-id="'+decodeURI(t)+'"]').length>0&&(i=jQuery('[ez-toc-data-id="'+decodeURI(t)+'"]').offset().top-i),jQuery("html, body").animate({scrollTop:i},500)})}); INLINESCROLLJS; wp_register_script( 'ez-toc-scroll-scriptjs', '', array( 'jquery' ), ezTOC::VERSION ); wp_enqueue_script( 'ez-toc-scroll-scriptjs', '', array( 'jquery' ), ezTOC::VERSION ); wp_add_inline_script( 'ez-toc-scroll-scriptjs', $inlineScrollJS ); }
How can I fix this error with modify the php code?
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘ReferenceError: jQuery is not defined at’ is closed to new replies.