我正在制作自己的wordpress主题。我几乎完成了它,但我还有一个小问题,我似乎无法弄明白。我尝试了以前的帖子也提出的一些事情,但是没有。我收到了这个错误:
!
按下此返回顶部按钮时出现错误:
Uncaught Error: Syntax error, unrecognized expression: https://ericgraventein.nl/wp-content/themes/twentyseventeen/#top
at Function.ga.error (jquery.js:1496)
at ga.tokenize (jquery.js:2113)
at ga.select (jquery.js:2517)
at Function.ga [as find] (jquery.js:893)
at m.fn.init.find (jquery.js:2733)
at new m.fn.init (jquery.js:2850)
at m (jquery.js:73)
at HTMLAnchorElement.<anonymous> (main.js:39)
at HTMLAnchorElement.dispatch (jquery.js:4670)
at HTMLAnchorElement.r.handle (jquery.js:4338)
这是来自我的.js文件:
<!-- back to top -->
<a id="mybutton" href="<?php bloginfo('template_url'); ?>/#top">
<img class="backtotop" src="<?php bloginfo('template_url'); ?>/images/backtotop.png" alt="backtotop">
</a>\
我尝试用“”东西包装'#mybutton',但这并没有产生任何结果。试过这个,因为其他帖子会用“#”包装标签#。提前谢谢!
编辑: 我还把它添加到我的functions.php
中// BACK TO TOP
var isVisible = false;
$(function()
{
$('#mybutton').on('click', function(e)
{
e.preventDefault();
$('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top}, 500, 'linear');
});
});
答案 0 :(得分:0)
此错误是因为jquery在'/'情况下不接受某些图表,并且像您的“ https://ericgraventein.nl/wp-content/themes/twentyseventeen/#top”一样抛出了此修复程序... 我希望它能为您提供帮助。
对不起,因为我的英语不好