Drupal 8 jQuery 3.3.1错误:语法错误,无法识别的表达式:ul.nav&;燃气轮机;李及;燃气轮机;应用javascript时出错
我是新手 (请参考此链接:-我正试图实现此链接) 我试图应用js文件,在引导导航的活动选项卡下面加下划线。当加载基于Drupal8中默认jquery的自定义js文件时,出现以下错误Drupal 8 jQuery 3.3.1错误:语法错误,无法识别的表达式:ul.nav&;燃气轮机;李及;燃气轮机;应用javascript时出错,javascript,jquery,css,drupal-8,jquery-3,Javascript,Jquery,Css,Drupal 8,Jquery 3,我是新手 (请参考此链接:-我正试图实现此链接) 我试图应用js文件,在引导导航的活动选项卡下面加下划线。当加载基于Drupal8中默认jquery的自定义js文件时,出现以下错误 Error: Syntax error, unrecognized expression: ul.nav > li > a jquery-3.3.1.js:1541:8 Sizzle</Sizzle.error https://code.jquery.com/jquery-3.3.
Error: Syntax error, unrecognized expression: ul.nav > li > a jquery-3.3.1.js:1541:8
Sizzle</Sizzle.error https://code.jquery.com/jquery-3.3.1.js:1541:8
Sizzle</Sizzle.tokenize https://code.jquery.com/jquery-3.3.1.js:2193:4
Sizzle</Sizzle.select https://code.jquery.com/jquery-3.3.1.js:2620:20
Sizzle https://code.jquery.com/jquery-3.3.1.js:845:9
.find https://code.jquery.com/jquery-3.3.1.js:2873:4
jQuery.fn.init https://code.jquery.com/jquery-3.3.1.js:2983:14
jQuery https://code.jquery.com/jquery-3.3.1.js:139:10
<anonymous> http://localhost:8080/developer-portal/htdocs/:1116:37
resolve/</mightThrow https://code.jquery.com/jquery-3.3.1.js:3534:21
resolve/</process< https://code.jquery.com/jquery-3.3.1.js:3602:12
在info.yml和libraries.yml文件中正确提及 Drupal转义您的js代码(
=>
)
您可以将js代码放入js文件中,并使用
标记导入代码
jQuery(document).ready(function () { console.log("highlight.js file executed... ggfh"); jQuery('ul.nav > li > a').click(function (e) { e.preventDefault(); jQuery('.initial-active').removeClass('initial-active'); jQuery('ul.nav > li > a').removeClass('active'); jQuery(this).addClass('active'); }); });