I have a form: http://jsfiddle.net/q2BnA/1/ . I want to be able to click on Option 1, and give focus to field1, click on Option 2, and give focus to field2. So, I have JQuery to do that. It works good, until I add this style:
input[type=checkbox], input[type=radio] {
display:none;
}
Now I have a problem in IE8 and IE7 (I have to support them) - focus is not given. I am assuming it's because of this line: var option1 = $('#option1').is(':checked');
But I have to hide radio buttons because I am styling my own via:
input[type=radio] + label {
/*look nice*/
}
How can I resolve this for IEs?
JQ
function focusThis() {
var option1 = $('#option1').is(':checked');
if (option1) {
//alert(1);
$('#field1').focus();
} else {
//alert(2);
$('#field2').focus();
}
}
HTML
<form>
<fieldset><legend>Options</legend>
<ul>
<li><input type="radio" name="A" id="option1" onclick="focusThis();"><label for="option1">Option 1</label>
<label for="field1">Field 1</label><input id="field1"/></li>
<li><input type="radio" name="A" id="option2" onclick="focusThis();"><label for="option2">Option 2</label>
<fieldset id=""><legend></legend>
<ul>
<li><label for="field2">Field 2</label> <input id="field2"/></li>
<li><label for="field3">Field 3</label> <input id="field3"/></li>
</ul>
</fieldset>
</li>
</ul>
</fieldset>
</form>