html5 - Want to make clickable cells of rows using jquery -
below code making rows clickable
$(document).ready(function () { $('#mytabledata').on('click', 'tr', function() {alert('hello');}); });
but want first 2 cells of rows clickable , how can make it?
try
$(document).ready(function () { $('#mytabledata').on('click', 'tr td:first-child,td:nth-child(2)', function() { alert('hello'); }); });
demo: fiddle
using :lt(2)
not work if there more 1 row: fiddle
if not want use event delegation
$(document).ready(function () { $('#mytabledata tr').find('td:lt(2)').click(function () { alert('hello'); }); });
demo: fiddle
Comments
Post a Comment