same origin class for different variable name buttons

13 Views Asked by At

I have different variable name buttons. I want them to have the same class.
I am hoping to make then only their reference is a different name. Then I can have a different listener on each one but the same appearance to them all. Apologies but I am sure this is where class constructor for objects comes in but just cannot grasp how that is done.

   let makeB = document.createElement('button');
   let makeB1 = document.createElement('button');
   let makeB2 = document.createElement('button');
   let makeB3 = document.createElement('button');
   makeB.classList.add('hidden');
   makeB.classList.add('variousStyles');
   //My buttons will all work but need to have less lines of code.
   //How can I make B,B1 etc all have the same attributes except name.
0

There are 0 best solutions below