Click on row except one specific td by jquery


<script type="text/javascript">


$(document).ready(function(){

$("#example").DataTable();
$("#example tbody").on("click","tr",function(e){
alert("clicked on tr");

var cell=$(e.target).closest('td');
if(cell.index()==5 ){
alert("Dont Run");
}
else{alert("Run");
}

});

});


\*\\\\\\\\\\\\\\\\\\\\\\\\\\Or you may use following also\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*\


$(document).ready(function(){

$("#example").DataTable();
$("#example tbody").on("click","tr",function(e){
alert("clicked on tr");

var cell=$(e.target).closest('td');
if(cell.index()!= 5 ){
 alert("Dont Run");
}

});

});


</script>


Download Demo Code

Comments

Popular posts from this blog

datatable with both top and bottom scroll bar.

How to set custom Post feature image as og:image ?