<div><span>Minsk</span><span>Minsk</span><span>Minsk</span><span>Minsk</span><span>Minsk</span><span>Minsk</span><span>Minsk</span>
</div>
<div><span>Minsk</span><span>Minsk</span><span>Minsk</span><span>Minsk</span><span>Moscow</span><span>Minsk</span><span>2.3</span><span>Minsk</span>
</div>
<script>
var span = document.querySelectorAll('span'), i = 0, j = 0;
while ( (span[i].textContent).indexOf("Moscow") == -1 && i < span.length && i < 100) { i++; };
while ( (span[i].textContent).indexOf("2.3") == -1 && i < span.length && j < 10) { i++; j++;}
[].forEach.call(span, function(elem) {
elem.addEventListener("click", function(e) {
alert(this.textContent);
});
});
var ev = new Event("click");
if(j > 0 && j < 10) span[i].dispatchEvent(ev);
</script>