I am trying to provide support for browsers which don't have support for the autofocus attribute, using an approach something like this:
<input type="text" autofocus/>
<input type="text" autofocus="autofocus"/>
<input type="text"/>
<script type="text/javascript">
$("input[autofocus]").first().focus();
</script>
However, that selector is returning all input elements for IE7, including ones that don't have an 'autofocus' attribute. Its working for IE8+, and I have tested using jQuery 1.6.4, 1.7.2 and 1.8.2. I have a jsfiddle here: http://jsfiddle.net/HSC7K/4/.
These jQuery tickets seems related, but have been closed:
http://bugs.jquery.com/ticket/5637
http://bugs.jquery.com/ticket/7874
Edit: updated jsfiddle: http://jsfiddle.net/HSC7K/6/