Jquery For Getting Click Event On A Table Row
I have the following table
How can i set an alert message if i
cell1 | cell2 |
Solution 1:
You can use delegate for better performance which will attach click event to root container of rows i.e table
$(document).ready(function(){
$("tableSelector").delegate("tr.rows", "click", function(){
alert("Click!");
});
});
Solution 2:
$(
function(){
$(".rows").click(
function(e){
alert("Clicked on row");
alert(e.target.innerHTML);
}
)
}
)
Better solution
$(document).on("click","tr.rows td", function(e){
alert(e.target.innerHTML);
});
Solution 3:
$(document).ready(function(){
$("tr.rows").click(function(){
alert("Click!");
});
});
Solution 4:
$(".rows").click(function (){
alert('click');
});
Post a Comment for "Jquery For Getting Click Event On A Table Row"