Answer the question
In order to leave comments, you need to log in
Why are css classes not being removed in the className method in ie 9-11?
There is such a function:
function toggleClass(elem,cls,flag){
var cls1=elem.className;
cls1=cls1.split(' ');
var i=cls1.indexOf(cls);
if ( (i >= 0 && flag > 0) || (i <0 && flag < 0)){
return;
}
if(flag < 0){
cls1.splice(i,1);
}
if(flag >= 0){
cls1.push(cls);
}
cls1=cls1.join(' ');
elem.className=cls1;
}
Answer the question
In order to leave comments, you need to log in
Here is the description of the method javascript.ru/Array/splice
Here is the line with the error: cls1.splice(i,1);
Here's a hint: array indexes start at zero.
That's why it doesn't delete.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question