有这样的js
$('a[href^="#"]').on('click', function (e) {
e.preventDefault();
var hrefAttr = $(this).attr("href");
parent = $(this).closest("ul");
parent.find("a").removeClass("active");
$(this).addClass("active");
if($(hrefAttr).length == 0) {
location.href='/'+hrefAttr;
} else {
if( hrefAttr.length > 0 && hrefAttr != "#") {
$('html, body').stop().animate({
'scrollTop': $(hrefAttr).offset().top-10
}, 500);
}
}
});
如果 $(hrefAttr) 元素丢失,则需要转到 location.href='/'+hrefAttr 并滚动到 $(hrefAttr)。滚动良好。但当你点击这个链接时
<a href="#" data-popup-link="callback">Заказать звонок</a>
给出一个错误
jquery.js?ver=1.0:1586 Uncaught Error: Syntax error, unrecognized expression: #
这就是该表格效果不佳的原因。
如何解决这个问题?

