Replacing a portion of code with a variable

How can I replace ClassName in the code below with a variable.

I have:

(function (root, factory) { factory((root.ClassName= {})); dragged =[].slice.call(_document.getElementsByClassName('ClassName')); }); 

How can I replace where I have class names with such a variable:

  (function (root, factory) { var x = ClassName factory((root.ClassName= {})); dragged =[].slice.call(_document.getElementsByClassName('ClassName')); }); 

Please note that this is only part of the code that I have, I do not need to change the code, I just need to call the variable in which these class names appear.

+5
source share
1 answer

Perhaps you are looking for something like this?

 function (root, factory) { var x = "ClassName"; factory((root[x]= {})); dragged = [].slice.call(_document.getElementsByClassName(x)); }; 
+4
source

All Articles