admin管理员组文章数量:1431955
Good day,
I have received the following error:
Uncaught Error: Syntax error, unrecognized expression: a[href*=#]:not([href=#])
for the library jquery-2.2.3.min.js:2
Below is the code:
$(document).ready(function() {
$('.collapse').on('show.bs.collapse', function() {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').addClass('active-faq');
$('a[href="#' + id + '"] .panel-title span').html('<i class="glyphicon glyphicon-minus"></i>');
});
$('.collapse').on('hide.bs.collapse', function() {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').removeClass('active-faq');
$('a[href="#' + id + '"] .panel-title span').html('<i class="glyphicon glyphicon-plus"></i>');
});
});
I am using the latest Jquery CDN
<!-- Javascript and Jquery files -->
<script src=".2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
Good day,
I have received the following error:
Uncaught Error: Syntax error, unrecognized expression: a[href*=#]:not([href=#])
for the library jquery-2.2.3.min.js:2
Below is the code:
$(document).ready(function() {
$('.collapse').on('show.bs.collapse', function() {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').addClass('active-faq');
$('a[href="#' + id + '"] .panel-title span').html('<i class="glyphicon glyphicon-minus"></i>');
});
$('.collapse').on('hide.bs.collapse', function() {
var id = $(this).attr('id');
$('a[href="#' + id + '"]').closest('.panel-heading').removeClass('active-faq');
$('a[href="#' + id + '"] .panel-title span').html('<i class="glyphicon glyphicon-plus"></i>');
});
});
I am using the latest Jquery CDN
<!-- Javascript and Jquery files -->
<script src="https://code.jquery./jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
Share
Improve this question
asked May 4, 2016 at 16:50
user5453902user5453902
1
- None of the code you've shown produces that selector? – Bergi Commented May 4, 2016 at 17:04
2 Answers
Reset to default 4The #
is a special character and needs to be escaped like:
'a[href*=\\#]:not([href=\\#])'
Source: https://github./jquery/jquery/issues/2885
If I understand what you are trying to do you seem to have an extra #
in your selector.
See this jsfiddle for a working example
本文标签: javascriptUncaught Error Syntax errorunrecognized expression ahref*not(href)Stack Overflow
版权声明:本文标题:javascript - Uncaught Error: Syntax error, unrecognized expression: a[href*=#]:not([href=#]) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745583390a2664750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论