For each element with class=required i want to addClass invalid after activate test() method at onclick Link, but it doesnt work. How to refer to an object?
theres a code:

```
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
.required {background-color:red;}
.invalid {background-color:blue !important;}
</style>

<script>
function test(){
$('.required').each(function(i,obj) {
$(obj).addClass("invalid");
});
}
</script>

</head>
<body>
<form method="get">
<input type="text" class="required" name="var"/>
<input type="text" class="required" name="var2"/>
<input type="submit" value="Submit"/>
</form>

<a onclick="test()" href="#">Link</a>

</body>
<html>

```