html5操作类名API——classlist

tagNode.classList.add('123'); // 添加类
tagNode.classList.remove('bbb'); // 删除类
tagNode.classList.toggle('eee'); // 切换类,如果有 eee 这个类则删除,没有则添加
tagNode.classList; // 返回DOMTokenList --- 类属性的实时集合


兼容性

猜你喜欢

转载自www.cnblogs.com/zhanghua-zh/p/10284586.html
今日推荐