Set first options selected using jquery

Posted by user947668 on Stack Overflow See other posts from Stack Overflow or by user947668
Published on 2012-11-23T22:27:40Z Indexed on 2012/11/23 23:04 UTC
Read the original article Hit count: 133

Filed under:

There are two options lists with different names, i need to set first options selected in both of them.

<input type="radio" name="first_list" value="0">abc
<input type="radio" name="first_list" value="1">cba

<input type="radio" name="second_list" value="0">opc
<input type="radio" name="second_list" value="1">cpo

Sure, i can do this way:

$("input:radio[name='first_list'][value='0']").attr("checked", "checked");
$("input:radio[name='second_list'][value='0']").attr("checked", "checked");

Maybe there is another more compact way to do this?

© Stack Overflow or respective owner

Related posts about jQuery