-1

新手来了

(请参考此链接:将Bootstrap Active nav-pills 选项卡边框底部形状更改为实线下划线 - 我试图实现这一点)

我试图应用 js 文件来强调引导导航药丸的活动选项卡。加载基于 drupal 8 中默认 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.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

请帮助解决此错误。

按照这里提到的子选择器,也用双引号括起来。但没有帮助。

使用的自定义jquery:

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'); }); });

在 info.yml 和 libraries.yml 文件中正确提及。

4

1 回答 1

0

Drupal 会转义您的 js 代码 ( >=> &gt;)。

您可以将您的 js 代码放在一个 js 文件中,并使用<script>标签导入您的代码。

于 2018-07-03T04:04:57.573 回答