0

I am a newbie in html and I m trying to set autofocus on an input text field...

But this is not supported in IE... is it possible to use JS in order to solve this problem?

3 Answers3

2

Javascript:

document.getElementById('elemID').focus();

jQuery:

$('selector').focus();
Matt K
  • 6,620
  • 3
  • 38
  • 60
0
<input type="text" id="aaa">
<script> 
    window.onload=function(){
        document.getElementById('aaa').focus();
    }
</script>
athspk
  • 6,722
  • 7
  • 37
  • 51
geekman
  • 2,224
  • 13
  • 17
0

Yes you can do this with javascript

e.g.

<script type="text/javascript">
   function formfocus() {
      document.getElementById('element').focus();
   }
   window.onload = formfocus;
</script>

Where 'element' is the id of your html input.

Baz
  • 5
  • 3