let isAlreadySelected = false; for (let i = 0; i < span.length; i++) { if (select.containsNode(span[i], true)) { isAlreadySelected = true; break; } }