zoukankan      html  css  js  c++  java
  • js操作元素className

    Base.prototype.addClass = function (className) {
    	for (var i = 0; i < this.elements.length; i ++) {
    		if (!this.elements[i].className.match(new RegExp('(\s|^)' + className + '(\s|$)'))){
    			  this.elements[i].className += ' ' + className;
    		}
    	}
    	return this;
    }
    //移除CLASS
    Base.prototype.removeClass = function (className) {
    	for (var i = 0; i < this.elements.length; i ++) {
    		if (this.elements[i].className.match(new RegExp('(\s|^)' + className + '(\s|$)'))){
    			this.elements[i].className = this.elements[i].className.
    			replace(new RegExp('(\s|^)' + className + '(\s|$)'), ' ');
    		}
    	}
    	return this;
    }
    
  • 相关阅读:
    接口类和抽象类
    生成器和迭代器
    装饰器
    KMP算法(java,c++)
    java EE
    XML
    SQL语法
    单元测试
    JDBC
    SpringCloud
  • 原文地址:https://www.cnblogs.com/fangxuele/p/5429089.html
Copyright © 2011-2022 走看看