You are comparing the same set of elements over and over again. You need to re-select the ones that you need during each check.
Change
required.each(function()
To
$([required]).each(function()
You are selecting all the element and then looping through them regardless of the properties that they now have. You want to have jQuery re-select the elements that now have the required
property so that you get an updated list. This should then perform as you expect.