Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing part of code with variable

Tags:

How can I replace a 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 the ClassNames with a variable like this:

 (function (root, factory) {

   var x = ClassName

   factory((root.ClassName= {})); 

   dragged =[].slice.call(_document.getElementsByClassName('ClassName'));

 });

Note that it is only a part of the code I have, I do not need to change the code, I just need to call a variable where those classnames are appearing.

like image 816
Bondsmith Avatar asked Jun 03 '16 01:06

Bondsmith


1 Answers

Are you perhaps looking for something like this?

function (root, factory) {
  var x = "ClassName";
  factory((root[x]= {}));
  dragged = [].slice.call(_document.getElementsByClassName(x));
};
like image 178
Hamms Avatar answered Sep 28 '22 02:09

Hamms