Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jquery滚动上的目标为空_Php_Jquery_Joomla_Scroll - Fatal编程技术网

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检查并更改您的$符号。