How do I simplify the following code?
It is just a static ID.
<script>
$x('input[id="id1"]').attr('checked', true);
$x('input[id="idx4"]').attr('checked', true);
$x('input[id="idk5"]').attr('checked', true);
</script>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just use the ID selector. You can select multiple elements by separating by comma:
Or if you are using jQuery 1.6 (or later) you should be using .prop() to set checked property: