简体   繁体   English

未捕获的TypeError:无法调用null的方法“ get”

[英]Uncaught TypeError: Cannot call method 'get' of null

I know there are many threads about this issue and i ve been looking for my specific case but i have not found anything relevant. 我知道有关此问题的话题很多,我一直在寻找我的具体案例,但我没有发现任何相关的内容。

I am implementing this javascript cashRegister effect in this page but i get this error msg 我正在此页面中实现此javascript cashRegister效果 ,但出现此错误msg

"Uncaught TypeError: Cannot call method 'get' of null" “未捕获的TypeError:无法调用null的方法'get'”

It points to the raw 18 of the plugin.js: 它指向plugin.js的原始18:

var current_value = this.element.get('text');

What might cause this error? 是什么导致此错误? What i should try to do now? 我现在应该尝试做什么?

Thanks 谢谢

I think your problem is at this line: 我认为您的问题出在这一行:

var total = $('total');

The selector total means "find elements with the name 'total'". 选择器total表示“查找名称为'total'的元素”。 What you really want is to find the element with the id of "total," so do this instead: 您真正想要的是找到ID为“ total”的元素,因此可以这样做:

var total = $('#total');

Edit : 编辑

I think some of the confusion stems from the fact that the $ in the site you're referencing is the $ from MooTools. 我觉得有些混乱的事实,茎$在你引用该网站是$从MooTools的。 In your page, you are including jQuery, which has an entirely different $ object that behaves differently. 在页面中,您包括jQuery,它有一个完全不同的$对象,其行为有所不同。 I believe that $('total') is how you select an element by ID in MooTools. 我相信$('total')是您在MooTools中通过ID选择元素的方式。

I'm not sure how you can load both libraries without having naming conflicts, but if you can figure that out, make sure you're using MooTools to select the total instead of jQuery. 我不确定如何在不引起命名冲突的情况下加载两个库,但是如果可以弄清楚,请确保使用MooTools选择总计而不是jQuery。

Edit 2 : 编辑2

After a bit of research (I'm unfamiliar with MooTools), I see that you could replace $('total') with: 经过一些研究(我对MooTools不熟悉),我发现您可以将$('total')替换$('total')

document.id('total')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的TypeError:无法调用null的方法“ appendChild”? - Uncaught TypeError: Cannot call method 'appendChild' of null? 未被捕获的TypeError:无法调用null的方法'getElementsByTagName' - Uncaught TypeError: Cannot call method 'getElementsByTagName' of null 未捕获的TypeError:无法调用null的方法“提交” - Uncaught TypeError: Cannot call method 'submit' of null 未捕获的TypeError:无法调用null的方法'replaceChild' - Uncaught TypeError: Cannot call method 'replaceChild' of null 未捕获的TypeError:无法调用null的方法“ menuAim” - Uncaught TypeError: Cannot call method 'menuAim' of null 未捕获的TypeError:无法调用null的方法'replace' - Uncaught TypeError: Cannot call method 'replace' of null 未捕获的TypeError:无法调用null的方法“ show” - Uncaught TypeError: Cannot call method 'show' of null 获取文本框输入的值:未捕获的TypeError:无法调用null的方法“ val” - Get value of textbox input: Uncaught TypeError: Cannot call method 'val' of null XML,JavaScript-未捕获的TypeError:无法调用方法'getElementsByTagName'为null - XML, Javascript - Uncaught TypeError: Cannot call method 'getElementsByTagName' of null 如何修复“Uncaught TypeError:无法调用方法'appendChild'的null” - How to fix “Uncaught TypeError: Cannot call method 'appendChild' of null”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM