I am trying to add a border around all items of a class when the mouse is hovering over it. However, no matter which item I hover over, the border is always applied to the last item on the page.
Could anyone explain what is going on and how I may fix it? Thanks.
function setAlertHovers(){
    var alerts = document.getElementsByClassName('alert');
    for(var i=0; i < alerts.length; i++)
    {
        var obj = alerts[i];
        obj.addEventListener('mouseover', function(){addBorder(obj);});
        obj.addEventListener('mouseout', function(){removeBorder(obj);});
    }
}
function addBorder(obj)
{
    obj.style.borderStyle = "solid";
}
function removeBorder(obj)
{
    obj.style.borderStyle = "none";
}
setAlertHovers();
