How to use 'changeclass' in JavaScript

Every line of 'changeclass' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
89function swap_classes(class1, class2) {
90 $container
91 .find('.'+class1).removeClass(class1).addClass('tmp-rtl-'+class1)
92 .end()
93 .find('.'+class2).removeClass(class2).addClass(class1)
94 .end()
95 .find('.tmp-rtl-'+class1).removeClass('tmp-rtl-'+class1).addClass(class2)
96}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

114function removeClass(ele,oldClass){
115 if (hasClass(ele,oldClass)) {
116 var arr = ele.className.split(/\s+/);
117 for (var i = 0; i < arr.length; i++) {
118 if(arr[i]===oldClass){
119 arr.splice(i,1);
120 break;
121 }
122 }
123 ele.className=arr.join(" ");
124 }
125}

Related snippets