Finding the element is one thing, updating a particularly indexed one is the question here.
Given basic HTML for a group of three checkboxes such as
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
Test!!!!!
<input name='cars' type='checkbox' value="primary" checked/>
<input name='cars' type='checkbox' value="secondary"/>
<input name='cars' type='checkbox' value="tertiary"/>
</body>
</html>
I can use jquery to select all the checkboxes with
$("input").prop( "checked", true );
However, how can I target just one checkbox such as the middle one?
I tried
$("input")[1].prop( "checked", true );
But I get prop is not a function
and $("input")[1].prop( "checked", true );
returns [] with no change.
It looks like I found one option which is a nested find, e.g.
$($("input")[1]).prop( "checked", true );
Is there a cleaner way than that?