I’m filtering XHTML classes; when there is only a single class it inserts a comma at the beginning. This makes classes that are hidden to have a value “,hidden” which ends up displaying hidden content. What am I missing? No frameworks please, I never use them.
var d = new Array();
for (var i=0;i<c.length;i++)
{
if (c[i]==c1) {d.push(c2);}
else if (c[i]==c2) {d.push(c1);}
else if (c[i]!='') {d.push(c[i]);}
}
d.join(' ');
alert(d);
d is still an array after using join().
Store the result of join() in a variable to get the resulting string: