jQuery Slider Uncaught TypeError:Object#< Object>没有方法'数据' [英] jQuery Slider Uncaught TypeError: Object #<Object> has no method 'data'

查看:98
本文介绍了jQuery Slider Uncaught TypeError:Object#< Object>没有方法'数据'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误 HERE

错误读取:
未捕获TypeError:对象#没有方法'数据'

The error reads: Uncaught TypeError: Object # has no method 'data'

我无法弄清楚这个错误源自何处!

I cannot figure out for the life of me where this error is originating from!

如果有人有任何线索,请告诉我!

If anyone has even the slightest clue, please let me know!

谢谢,

Evan

推荐答案

它起源于jquery.nivo.slider.pack.js,更确切地说是抱怨element.data不是第67行的函数(Firebug是这种调试的一个很好的工具: - ))。我不完全确定,但可能是因为你的html中有以下代码:

It's originating from "jquery.nivo.slider.pack.js" and more precisely is complaining about element.data is not a function at line 67 (Firebug is a great tool for such debugging :-) ). I am not entirely sure, but it could be because of the following code in your html:

<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider();
});
</script>

$(窗口).load会在窗口加载时立即触发,此时它可能会被激活滑块div不存在于DOM中。因此,请尝试将其更改为:

$(window).load will fire as soon as the window is loaded at which point it could be that the slider div is not present in the DOM. So, try changing this to:

<script type="text/javascript">
$(document).ready(function() {
    $('#slider').nivoSlider();
});
</script>

这将确保DOM已被绘制并可供插件使用。此外,看起来插件需要一个'element'参数,而你传递none,这可能是element.data未定义的原因。为此您可以尝试:

This will ensure that the DOM has been painted and available for the plugin to work on. Also, it looks like the plugin expects an 'element' argument, whereas you are passing none, which could be the reason for element.data to be undefined. For this you can try:

$('#slider').nivoSlider($(this));

希望其中一个适合你。

这篇关于jQuery Slider Uncaught TypeError:Object#&lt; Object&gt;没有方法'数据'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆