<div class="tags">
<span id="tag_4" class="tag">tagname</span>
<span id="tag_1" class="tag">tagname</span>
<span id="tag_6" class="tag">tagname</span>
<span id="tag_3" class="tag">tagname</span>
<span id="tag_15" class="tag">tagname</span>
<span id="tag_8" class="tag">tagname</span>
</div>
<div class="tags">
элементов не найдено, получить единицу. tags = document.querySelectorAll('span[id^=tag]');
var n =1;
for(var i in tags){
var n2 = Number(tags[i].id.replace(\tag_/,'') );
if(n2) > n)
n = n2;
}
var a = [2,3,1,10,25,2,4,7], maxValue = Math.max.apply(Math, a);
alert(maxValue)
var oneElementOfArray = Numbser(span.id.substr(4)) || 0