0

这个脚本在这里工作https://jsfiddle.net/ByEzF/但在停止工作的站点中:

<script type="text/javascript">
    var Add = {
        setOptions: function(number) {
            $('battle-options')
            .removeClass('five-options')
            .removeClass('four-options')
            .removeClass('three-options')
            .removeClass('two-options');

            var option3 = $('option-3');
            var option4 = $('option-4');
            var option5 = $('option-5');

            var versus3 = $('versus-3');
            var versus4 = $('versus-4');
            var versus5 = $('versus-5');

            var elements5 = new Elements([option3, option4, option5, versus3, versus4, versus5]);
            elements5.setStyle('display','none');

            if(number == 5) {
                $('battle-options').addClass('five-options');
                elements5.setStyle('display','block');
                $$('.battle-option input[type="file"]').set('size', 10);
            } else if(number == 4) {
                $('battle-options').addClass('four-options');
                new Elements([option3, option4, versus3, versus4]).setStyle('display','block');
                $$('.battle-option input[type="file"]').set('size', 15);
            } else if(number == 3) {
                $('battle-options').addClass('three-options');
                new Elements([option3, versus3]).setStyle('display','block');
                $$('.battle-option input[type="file"]').set('size', 19);
            } else if(number == 2) {
                $('battle-options').addClass('two-options');
                $$('.battle-option input[type="file"]').set('size', 22);
            }
        }
    };

    window.addEvent('domready', function(){
        Add.setOptions(2);
    });
</script>

我有这个错误信息:

未捕获的 TypeError:[对象窗口] 没有方法“addEvent”?

4

1 回答 1

4

window.addEvent只能通过 MooTools 获得(正在加载到 jsfiddle 页面上)。

https://mootools.net/docs/core/Element/Element.Event

从文档:

注意:此方法也附加到 Document 和 Window。

于 2012-05-22T15:47:53.143 回答