Jquery jscrollpane plugin error

时间秒杀一切 提交于 2019-12-11 03:53:34

问题


I get this error when I try and implement jSrollpane in Safari 4:

TypeError: Result of expression '$drag[0]' [undefined] is not an object.

Then i get this error when i try the same thing in Chrome:

Uncaught TypeError: Cannot read property 'offsetHeight' of undefined

But why? it works fine in FF.

Any ideas?


回答1:


It appears that jQuery does not manage to resolve the child selector (“parent > child”), thus both "$track" and "$drag" are set to undefined values:

$track = $('>.jScrollPaneTrack', $container);
$drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container);

As a result, the scrollbar does not initialize, and simply does nothing Replacing the previous lines with a "dumbed down" version fixes the issue:

$track = $container.children(".jScrollPaneTrack");
$drag = $track.children(".jScrollPaneDrag");


来源:https://stackoverflow.com/questions/2131629/jquery-jscrollpane-plugin-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!