$(document).ready(function(){ $('.txtDate').datepicker({ showOn: 'both', buttonImage: 'library/ui/datepicker/img/calendar2.gif', dateFormat: 'yy/mm/dd', buttonImageOnly: true }); //added this checkbox click for something I given earlier $('#Table input').click(function() { if ($(this).attr('checked') == true) { $(this).parent().parent().addClass('highlight'); } else { $(this).parent().parent().removeClass('highlight'); } }); });
I have a checkbox control for each row that I add dynamically in code behind
for( int i=0; i< data.count;i++){ HtmlTableCell CheckCell = new HtmlTableCell(); CheckBox Check = new CheckBox(); CheckCell.Controls.Add(Check); row.Cells.Add(CheckCell); Table.Rows.Add(row); }
table id with markup is here:
<table id='Table' runat='server' width='100%' cellspacing='5' border='1'> <colgroup width='3%'></colgroup> <colgroup width='15%'></colgroup> <colgroup width='20%'></colgroup> <colgroup width='15%'></colgroup> <colgroup width='47%'></colgroup> <thead> <tr> <th id='CheckBox' runat='server'><input type='checkbox' id='CheckBox1' name='CheckBox' runat='server' /></th> <th id='Type' runat='server'></th> <th id='Category' runat='server'></th> <th id='DateTime' runat='server'></th> <th id='Description' runat='server'></th> </tr> </thead> <tbody> </tbody> </table>
Yea – my answer just got zapped too.
Anyway, if you are using asp.net then the names get mangled ( to something like ctl100_Table ) and you need to put this into the jquery instead of Table.
Look at the actual rendered html in the browser to get the name you need to use.
You can try using $(‘[id$=Table]).attr(‘id’) to get the mangled version.