[Solved] JavaScript: click event for same class name

[ad_1]

label is an array of all the elements with class text, so label[0] will only apply to the first element in the document. Simplest way to do it would probably be with a loop such as

for (var i = 0; i<label.length; i++){
    label[i].onclick = function() {
        console.log(true);
};

[ad_2]

solved JavaScript: click event for same class name