Question: `EDIT` Helping people understand the question better

Can you call a argument and then use it in jQuery? I was thinking something like:

```
// Notice the "test" argument in the "foo" function
function foo(test) {
  $("#randomDiv").click(function(){
    $(test).toggle();
  });
}

```

Would something like this work?

Answer: 
You can use pure jQuery to select the first invalid input:

`$('input.ng-invalid').first().focus();`
A minor tweak with what @Sajan said worked for me,

```
angular.element("[name='" + this.formName.$name + "']").find('.ng-invalid:visible:first')[0].focus();

```