Setting focus on a form element using JavaScript is usually very straight forward. I cannot get this working in Firefox 12.0 or Opera 11.
Works in other browsers (Chrome, IE etc) and Firefox 3.6.
Simple HTML:
<form action="">
<input type="radio" id="focusID1" name="sex" value="male" /> Male<br />
<input type="radio" id="focusID2" name="sex" value="female" /> Female<br />
</form>
Simple Javascript:
var elem = document.getElementById("focusID2");
if (elem != null) {
elem.focus();
}
Try this for yourself at http://jsfiddle.net/4Ddtv/.
Firefox was working as expected. Issue was with jsfiddle focus and firefox not highlighting the focused element.
This is not an issue.. User error!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With