无法读取属性&#39;&lt; <functionname>&gt;&#39;未定义的

时间:2018-06-07 16:09:16

标签: javascript object methods undefined

我创建了一个JavaScript,可以在其中一个页面上添加甘特图滚动。我的脚本如下:

<script>SP.SOD.executeOrDelayUntilScriptLoaded(ScrollToToday,'jsgrid.js');

function ScrollToToday(){

setTimeout(function(){

$("div[id$='_ListViewWebPartJSGrid']")[0].jsgrid.ScrollGanttToDate(new Date());

}, 1000);

}
</script>

脚本没有做任何事情。当我调试代码并在浏览器控制台中添加了行$("div[id$='_ListViewWebPartJSGrid']")[0].jsgrid.时,我发现附加到jsgrid对象的函数。但是,当在浏览器控制台中添加该行时,$("div[id$='_ListViewWebPartJSGrid']")[0].jsgrid.ScrollGanttToDate(new Date());它会向我显示错误Cannot read property 'ScrollGanttToDate' of undefined

enter image description here

我该如何解决这个问题?

0 个答案:

没有答案