在javascript for chrome中使用元素属性作为属性

在javascript for chrome中使用元素属性作为属性,javascript,jquery,html,Javascript,Jquery,Html,我有一个函数,它定义标记是可见的还是不可见的,不管发生什么奇怪的事情。如果我在InternetExplorer中使用它,它可以正常工作,但在chrome中我会遇到很多错误,我已经尝试过用Workaround模拟逻辑,但它不会给我相同的结果 var attrs = new Array(); if (isChrome) { if (!GUIElm.getAttribute("filteredby")) { GUIElm.setAttribute("filteredby"

我有一个函数,它定义标记是可见的还是不可见的,不管发生什么奇怪的事情。如果我在InternetExplorer中使用它,它可以正常工作,但在chrome中我会遇到很多错误,我已经尝试过用Workaround模拟逻辑,但它不会给我相同的结果

var attrs = new Array();
if (isChrome) {


    if (!GUIElm.getAttribute("filteredby")) {

        GUIElm.setAttribute("filteredby", new Array());
    }
    attrs.slice(columnIdx,1);
    $(GUIElm).prop('disabled', true);
    if (filterObj.filters(value)) {
        attrs.push(columnIdx);
        GUIElm.setAttribute("filteredby", attrs)
    }

    GUIElm.style.display = (attrs.length == 0) ? "" : "none";
}
else { //Internet explorer
    if (typeof (GUIElm.filteredby) == "undefined") {
        GUIElm.setAttribute("filteredby", new Array());
    }
     GUIElm.filteredby.remove(columnIdx); // accessing the attribute as an object property
    if (filterObj.filters(value)) {

        GUIElm.filteredby.push(columnIdx);
    }
    GUIElm.style.display = (GUIElm.filteredby.length == 0) ? "" : "none";
}
谢谢。

我使用了$.data(),它具有所需的行为

  $(GUIElm).data('filteredby', []);
  $(GUIElm).data('flag', 30292);                 
  $(GUIElm).data('filteredby').slice(columnIdx);

你能用你看到的错误更新你的问题吗?你收到的错误是什么?chrome中的错误:GUIElm.filteredby.remove(columnIdx)//无法读取未定义的属性“remove”。通常,不应向DOM元素添加自定义属性;如果您需要向DOM元素添加自定义数据,您应该使用API。我认为属性只能包含字符串,不能包含对象或数组。