I want to loop though some links and add a number to the href, so it would be something like `x.php&ref=333`.

```
<div id="maindiv">
<span><a href="x.php&ref="></a></span>
<span><a href="x.php&ref="></a></span>
<span><a href="x.php&ref="></a></span>
</div>

```

How do I write this in pure javascript? Here is the jQuery code:

```
$('#maindiv a').each(function(){
var hr = $(this).attr('href');
$(this).attr('href' , hr+333 );
})

```

For some reason I can't use that and need to write the code in pure javascript .
Specifically, I don't know how to get each `a` element.