未捕获的错误:语法错误,无法识别的表达式:/ [英] Uncaught Error: Syntax error, unrecognized expression: /
本文介绍了未捕获的错误:语法错误,无法识别的表达式:/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我仅在主页上收到此错误.我该如何解决?
如果我访问example.com
,但是当我访问example.com/index.html
I'm receiving this error only in home page. How do I solve this?
If I visit example.com
but it works good when I visit example.com/index.html
$(document).ready(function() {
var url =
window.location.href;
var start = url.substr(url.indexOf("#"));
$(start).collapse('show');
$('.collapse.in').prev('.panel-heading').addClass('active');
$("#accordion, #bs-collapse").on("show.bs.collapse", function(a) {
$(a.target).prev('.panel-heading').addClass('active');
var curr =
$(a.target).attr("id");
var url = window.location.href;
var start = window.location.hash;
if (start.length > 0) {
window.location.href = url.replace(start, "#" + curr);
} else {
window.location.href = url + "#" + curr;
}
$("#accordion, #bs-collapse").on('hide.bs.collapse',
function(a) {
$(a.target).prev('.panel-heading').removeClass('active');
});
});
});
推荐答案
尝试以下代码
您只需要在您的payments.html页面中使用这些代码.但是它在任何地方都被调用,会导致错误
you only need these code in your payments.html page.But it gets called every where,it cause the error
$(document).ready(function() {
if ($(".panel-group").length > 0) {
var url = window.location.href;
var start = url.substr(url.indexOf("#"));
$(start).collapse('show');
$('.collapse.in').prev('.panel-heading').addClass('active');
$("#accordion, #bs-collapse").on("show.bs.collapse", function(a) {
$(a.target).prev('.panel-heading').addClass('active');
var curr =
$(a.target).attr("id");
var url = window.location.href;
var start = window.location.hash;
if (start.length > 0) {
window.location.href = url.replace(start, "#" + curr);
} else {
window.location.href = url + "#" + curr;
}
$("#accordion, #bs-collapse").on('hide.bs.collapse',
function(a) {
$(a.target).prev('.panel-heading').removeClass('active');
});
});
}
});
这篇关于未捕获的错误:语法错误,无法识别的表达式:/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文