JavaScript custom addclass function code

From , 5 Years ago, written in JavaScript, viewed 89 times.
URL https://pastebin.vip/view/8682cc30
  1. function addClass(id,new_class){
  2.        var i,n=0;
  3.  
  4.        new_class=new_class.split(",");
  5.  
  6.        for(i=0;i<new_class.length;i++){
  7.                if((" "+document.getElementById(id).className+" ").indexOf(" "+new_class[i]+" ")==-1){
  8.                        document.getElementById(id).className+=" "+new_class[i];
  9.                        n++;
  10.                }
  11.        }
  12.  
  13.        return n;
  14. }
  15.  
  16.  
  17. //javascript/4104

Reply to "JavaScript custom addclass function code"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website