Set focus on a div after form is submitted

Set focus on a div after form is submitted

Hello all,

I've been working with a fairly simple contact form that emails info to a client when it's submitted. within the <form></form> tags, i have <div id="response"></div> which is where my "success" or "fail" messages appear after the form is submitted. 

I would like to set the focus on that div after the form is submitted but can't seem to work out how to do that.

So far i have tried adding

  1. onSubmit="$('form #response).focus();
to the form, but it isn't doing anything.

I've also tried:
  1. <script type="text/javascript">
  2. $('#agent').submit(function() {
  3. $('#response').focus();
  4. });
  5. </script>
where #agent is the form's ID but that doesn't seem to work either.

Can anyone point me in the right direction?

Thanks in advance,
Jason