TypeError:param.toElement未定义 [英] TypeError: param.toElement is undefined

查看:48
本文介绍了TypeError:param.toElement未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我所有的代码都是Prototype JS和Jquery的混合:

Hey all I have the following code that's a mix of Prototype JS and Jquery:

var oldZindex = 0;
var theClickID = null;

UIProgressButton.prototype._initEvents = function() {
    var self = this;
    this.button.addEventListener( 'click', function(param) {
        $('#overlay').css({'visibility':'visible'});
        theClickID = $('button[data-id="' + param.toElement.attributes[1].value + '"]').parent().attr('id');
        oldZindex = $('#' + theClickID).css('z-index');
    });
}

此代码在Chrome浏览器中可以正常工作,但似乎会引发以下错误:

This code works just fine in a Chrome Browser but seems to throw the error of:

typeerror param.toelement未定义

typeerror param.toelement is undefined

在FireFox中....我将如何解决此问题,因为我知道它确实可以正常工作,因为它可以在Chrome中正常工作?

In FireFox.... How would I go about fixing this issue since I know for a fact that it does work since its working in Chrome just fine?

推荐答案

由于您已经有了jQuery,因此可以使用它来绑定事件侦听器,这样您就不会在IE上遇到麻烦:

Since you already have jQuery you could use it to bind your event listeners so you don't have the IE trouble in getting the event:

var oldZindex = 0;
var theClickID = null;

UIProgressButton.prototype._initEvents = function() {
    var self = this;
    $(this.button).on( 'click', function(param) {
        $('#overlay').css({'visibility':'visible'});
        theClickID = $('button[data-id="' 
          //you may prefer to get a named attribute
          //instead of by index:
          //param.getAttribute('attributeName')
          + param.target.attributes[1].value 
          + '"]').parent().attr('id');
        oldZindex = $('#' + theClickID).css('z-index');
    });
}

这篇关于TypeError:param.toElement未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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