Php jquery滚动上的目标为空
我一直在尝试实现一个滚动脚本,它将从菜单项名称平滑地过渡到相关的Php jquery滚动上的目标为空,php,jquery,joomla,scroll,Php,Jquery,Joomla,Scroll,我一直在尝试实现一个滚动脚本,它将从菜单项名称平滑地过渡到相关的a名称值。以下是脚本: $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') || location.hostname == this.hostname) { var target = $(this.hash);
a名称
值。以下是脚本:
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
这正在Joomla 3站点上实施。我已经在CMS之外的一个空白php
脚本上测试了这个脚本,它似乎工作得很好。控制台错误显示为TypeError:target为null
target=target.length?目标:$('[name='+this.hash.slice(1)+']')代码>正如您所说,它在seprate页面上工作,所以,您是否检查了可能是您的jquery冲突!!!把你的$符号换成joomla
希望能对你有所帮助 你把Joomla的$符号改了是什么意思?啊,现在可以了。。。我将$
更改为jQuery
,现在很好。谢谢。用jQuery检查并更改您的$符号。