I got getting class "index" from data but the problem is that :
When I add new button, it doesnt call "class index" Whe I click it.. Where is the mistake?
function addbutton(id)
{
newtag = document.createElement("button");
newtag.classList.add("trying");
newtag.innerHTML = "WHen I button that button it doesnt call function grupla() function";
divarea = document.getElementById("kanban_1");
divarea.appendChild(newtag);
};
var elems = Array.from(document.querySelectorAll('.trying'));
elems.forEach(el => el.addEventListener('click', grupla));
function grupla()
{
var index = elems.indexOf(this);
alert(index);
};
<button class="trying">Which Class</button>
<button class="trying">Which Class</button>
<button class="trying">Which Class</button>
<button class="trying">Which Class</button>
<button class="trying">Which Class</button>
<button class="trying">Which Class</button>
<button onclick="addbutton(this.id)">add</button>
<div id="kanban_1"> </div>