0

我在使用 jquery.ui.richmedia.js 时遇到问题。

“对象不支持此属性或方法”出现此错误

“toremoveTabs[i].hide()”就是这行代码。我相信它与 hide() 方法有关,因为“toremoveTabs [i]”在代码中的其他地方工作正常。该代码在 Mozilla 和 Chrome 中运行良好。

       resetTabs:function () {
        // remove unavailable tabs.
        var toremoveTabs = [];
        var toremoveTabNames = [];
        this._forEachTab(function (tab, i, self) {
            if (self._tabs) {
                tab = $(tab);
                var tabName = self._getTabName(tab.attr('content_id')).toLowerCase();
                if (!(tabName in self._tabs)) {
                    toremoveTabs[i] = tab;
                    toremoveTabNames[i] = tabName;
                }
            }
        });
        this._appendTabs = null;
        this._appendTabs = {};
        for (var i in toremoveTabs) {
            this._appendTabs[i] = [toremoveTabNames[i], toremoveTabs[i]];
            toremoveTabs[i].hide();
        }
    } 

任何人都可以提出解决方法/解决方案吗?

4

1 回答 1

6

I would guess that toremoveTabs[i] isn't a jQuery object, and is instead a regular DOM node, and as a result has no .hide() function available. Wrap it in a call to the jQuery function to create a jQuery object, giving you access to that function:

jQuery(toremoveTabs[i]).hide();
于 2013-10-10T14:51:09.460 回答