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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -