Click here to Skip to main content
15,921,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
I'm dynamically creating rows in table. I want to bind click event for the 2 column of each row.

I tried following code:
JavaScript
$(gridTask).on('click', 'tr td:first-child', function () {
    alert($(this).find('hdnDDLValues').length);
});


Above code works fine, if i click on 1 column of each row. But my first column has checkbox and I want to raise click event whenever user clicks on second column.

I modified above
JavaScript
$(gridTask).on('click', 'tr td:eq(1)', function () {
    alert($(this).find('hdnDDLValues').length);
});


I works only for first row, when I click the 2 column of any other row event is not raised.

Any idea, how to do it??

Thanks in advance.
Posted

1 solution

I just made use of nth-child and it worked fine.


JavaScript
$(gridTask).on('click', 'tr td:nth-child(2)', function () {
                    alert($(this).find('hdnDDLValues').length);
            });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900