var totales = 0;
function buscarLinks(){
var links = document.getElementsByTagName("A");
var i=0,
linkse=links.length;
for(;i<linkse;i++){
if(links[i].href == 'prueba') totales++;
}
}
console.log(totales);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body onload="buscarLinks();">
<a href="prueba">prueba real 1</a>
<hr>
<a href="http://gg">prueba FALSA</a>
<hr>
<a href="prueba">prueba real 2</a>
</body>
</html>
I try to count the A tags but I always get 0, why?