[jQuery] next closet or what
I am trying to get the next function working
this works
<table >
<form method="post" id="frmOne">
<tr>
<th>Name</th>
<th>Location</th>
</tr>
<tr id="3">
<td id="2"><input type="checkbox" class="checkbox" name="ss"
value="1"> Spiraldev
<input type="checkbox" id="rr" class="checkbox" name="ss"
value="1"> Sac Town</td>
</tr>
</form>
</table>
<script>
$(document).ready(
function(){
$( "input.checkbox" ).click(
function(){
if($(this).attr('checked') == true){
var el = $(this).next();
alert($(this).next().attr('id'))
$(this).next('[type=checkbox]]').attr('checked',true)
}else{
$(this).next('[type=checkbox]]').attr('checked',false)
}
}
);
}
);
</script>
but this does not work
<table >
<form method="post" id="frmOne">
<tr>
<th>Name</th>
<th>Location</th>
</tr>
<tr id="3">
<td id="2"><input type="checkbox" class="checkbox" name="ss"
value="1"> Spiraldev</td>
<td><input type="checkbox" id="rr" class="checkbox" name="ss"
value="1"> Sac Town</td>
</tr>
</form>
</table>
<script>
$(document).ready(
function(){
$( "input.checkbox" ).click(
function(){
if($(this).attr('checked') == true){
var el = $(this).next();
alert($(this).next().attr('id'))
$(this).next('[type=checkbox]]').attr('checked',true)
}else{
$(this).next('[type=checkbox]]').attr('checked',false)
}
}
);
}
);
</script>