hasclass,removeClass

3322 단어 removeClass
var TH = TH || {};

TH.extend = function(first, second){

    for (var prop in second){

        first[prop] = second[prop];

    }

}; 

TH.css = function(element, styles){

    if (styles.opacity != null){

        if (typeof element.style.opacity != 'string' && typeof(element.filters) != 'undefined'){

            styles.filter = 'alpha(opacity=' + Math.round(100 * styles.opacity) + ')';

        }

    }

    TH.extend(element.style, styles);

};

TH.hasClass = function(element, name){

    var re = new RegExp('(^| )' + name + '( |$)');

    return re.test(element.className);

};

TH.addClass = function(element, name){

    if (!TH.hasClass(element, name)){

        element.className += ' ' + name;

    }

};

TH.removeClass = function(element, name){

    var re = new RegExp('(^| )' + name + '( |$)');

    element.className = element.className.replace(re, ' ').replace(/^\s+|\s+$/g, "");

};

좋은 웹페이지 즐겨찾기