I have a html table with many cells and I would like to set a checkbox field as enabled with style="display: none" when somebody tries to click on a particular cell. I should reset this when the user clicks on the same cell again. How should I do this using jquery?
views:
35answers:
3
+1
A:
The following assumes the checkbox is inside the <td> that has been clicked:
$('td').each(function(){
$(this).click(function(){
$(this).find('input:checkbox').toggle();
});
});
If there's only one global checkbox for all cells, you can just reference it directly instead of doing the find():
$('#checkbox-id').toggle();
Pat
2010-07-16 12:43:15
+1
A:
$('table td').click(function(){
$(this).children('input:checkbox').attr('checked', 'checked').toggle('slow');
});
Live example : http://jsfiddle.net/p9rRY/
Philippe
2010-07-16 13:32:06
+1
A:
you can use this script to show/hide check box in particular column.
$('table tr td:eq(1)').toggle(function(){ $(this).children(':checkbox').css('display','block');}, function(){ $(this).children(':checkbox').css('display','none');});
Please give specific column index in "eq(index)" where you wanna click to show/hide checkbox. for example in above script column is "1". column index start from 0
Deepak
2010-07-16 17:55:04