comparison default/node_modules/shoestring/src/dom/removeClass.js @ 0:1d038bc9b3d2 default tip

Up:default
author Liny <dev@neowd.com>
date Sat, 31 May 2025 09:21:51 +0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1d038bc9b3d2
1 //>>excludeStart("exclude", pragmas.exclude);
2 define([ "shoestring" ], function(){
3 //>>excludeEnd("exclude");
4
5 /**
6 * Remove a class from each DOM element in the set of elements.
7 *
8 * @param {string} className The name of the class to be removed.
9 * @return shoestring
10 * @this shoestring
11 */
12 shoestring.fn.removeClass = function( cname ){
13 var classes = cname.replace(/^\s+|\s+$/g, '').split( " " );
14
15 return this.each(function(){
16 var newClassName, regex;
17
18 for( var i = 0, il = classes.length; i < il; i++ ){
19 if( this.className !== undefined ){
20 regex = new RegExp( "(^|\\s)" + classes[ i ] + "($|\\s)", "gmi" );
21 newClassName = this.className.replace( regex, " " );
22
23 this.className = newClassName.replace(/^\s+|\s+$/g, '');
24 }
25 }
26 });
27 };
28
29 //>>excludeStart("exclude", pragmas.exclude);
30 });
31 //>>excludeEnd("exclude");