Adding a class using JavaScript -
could give me hand following javascript issue.
i trying come function adds class div has specified class.
i have tried come based on few people have said doesn't seem work.
http://jsfiddle.net/samsungbrown/vz9hu/
where going wrong?
thanks
function toggleclass(matchclass,content) { var elems = document.getelementsbytagname('*'),i; (i in elems) { if((" "+elems[i].classname+" ").indexof(" "+matchclass+" ") > -1) { elems[i].classlist.toggle(content); } } } window.onload = function () { toggleclass("col-left","display"); }
because of quirks in jsfiddle code doesn't run. remove .onload
wrapper , code runs. see: http://jsfiddle.net/vz9hu/1/
Comments
Post a Comment