//添加classDOMTokenList.prototype.adds = function(tokens) { tokens.split(" ").forEach(function(token) { this.add(token); }.bind(this)); return this; }; var clList = document.body.classList; clList.adds("child1 child2 child3").toString(); // "a b c child1 child2 child3" //移除classDOMTokenList.prototype.removes = function(tokens) { tokens.split(" ").forEach(function(token) { this.remove(token); }.bind(this));return this;};
var clList = document.body.classList; clList.removes("child1 child2 child3").toString(); // "a b c child1 child2 child3"
时间: 2024-10-11 06:04:04