Произошла ошибка.
Пожалуйста, обновите страницу.
Fly.js > Документация > Проверки > $(...).hasClass()

$(...).hasClass()

Проверяет наличие каждого из переданных классов для каждого элемента текущей FlyNode.

#Проверки #Изменение DOM #Стили

$(...).hasClass(class1, [class2], [classN])

                    FlyDomNode: {
                        __constructor: function(context) {
                            var array = fnNodeList.makeDomNodeArray(context);
                            for (var a = 0, al = array.length; a < al; a++) {
                                this[a] = array[a];
                            }
                            this.length = al;
                        },

                        size: function() {
                            return this.length;
                        },

                        get: function(index) {
                            return $.isNumber(index) ? this[index] : [].slice.call(this);
                        },

                        addNode: function(flyNode) {
                            return fnNodeList.changeNodeContext(this, flyNode, function(child, context) {
                                context.indexOf(child) === -1 && context.push(child);
                            });
                        },

                        removeNode: function(flyNode) {
                            return fnNodeList.changeNodeContext(this, flyNode, function(child, context) {
                                var position = context.indexOf(child);
                                if (position !== -1) context.splice(position, 1);
                            });
                        },

                        eq: function(index) {
                            if (index < 0) index = index + this.length;
                            return new this.__self(this[index]);
                        },

                        lt: function(index) {
                            return new this.__self(this.slice(0, index));
                        },

                        gt: function(index) {
                            return new this.__self(this.slice(index));
                        },

                        last: function(selector) {
                            var element = this[this.length - 1];
                            return new this.__self(fnStyle.isMatch(element, selector) ? element : []);
                        },

                        first: function(selector) {
                            var element = this[0];
                            return new this.__self(fnStyle.isMatch(element, selector) ? element : []);
                        },

                        normalize: function() {
                            return fnNodeList.transformNodeContext(this, function(item, context) {
                                if ($.isNode(item)) context.push(item);
                            });
                        },

                        each: function(callback, context) {
                            $.each(this, callback, context);
                            return this;
                        },

                        name: function() {
                            return this[0].tagName.toLowerCase() || null;
                        }
                    }
                

$(...).hasClass(class1, [class2], [classN])
Возвращает: Boolean !!

Проверяет наличие каждого из переданных классов для каждого элемента текущей FlyNode.

class1: String ABC

Название класса для проверки.

class2: String ABC

Название класса для проверки.

classN: String ABC

Название класса для проверки.

Если хотя бы у одного элемента не найден хотя бы один класс из списка, то метод вернёт false. Если каждый элемент текущей FlyNode содержит все классы из списка, то метод вернёт true.

Параметры class1, class2, classN... могут содержать строку с несколькими классами, разделёнными пробелами.

Пример: Проверка наличия классов на DOM узлах.

<!DOCTYPE html>
    <head>
        <meta charset="utf-8"/>
        <title>Fly.js - $(...).hasClass()</title>

        <script src="/scripts/fly.js"></script>
    </head>
    <body>
        <div class="one div">I am the first DIV!</div>
        <div class="two div">I am the second DIV!</div>
        <p></p>

        <script>
            $('p').html([
                $('div').hasClass('div'),
                $('div').hasClass('two', 'div'),
                $('.two').hasClass('one two div')
            ].join(' '));
        </script>
    </body>
</html>