$('tr').click(functi开发者_运维技巧on() {
$("#showgrid").load('/Products/List/Items/');
});
Using this I am handling click event on the row of the table.
How can I handle only on the first column? that is, giving click action to only first column not on entire row?
thanks
You can handle the first column using :first-child
selector, like this:
$('tr td:first-child').click(function() {
$("#showgrid").load('/Products/List/Items/');
});
This selector returns the first <td>
in each <tr>
.
Alternatively, if you have a lot of rows, use .delegate()
for better performance (only one event handler), like this:
$('#myTable').delegate('tr td:first-child', 'click', function() {
$('#showgrid').load('/Products/List/Items/');
});
that is simple. just add an event handler to the first td of each tr of the table. this jQuery code is almost like speaking it.
$("#table tr").find("td:first").click(function() {
$("#showgrid").load('/Products/List/Items/');
});
精彩评论