简体   繁体   中英

How to get table row specific column to be clicked using javascript?

I have given row a class name , and i want to set a click function to be clicked on specific column of that row.

Here is the code-

var row = $('<tr class="parent_row"><td>' + '</td>' + '<td>' + data1 + '</td>' + '<td>' 
+  data2  + '</td>; + '<td>' + data3 + "</td></tr>"

My click functon-

$('.parent_row).find("td:eq(1)").(click(function(e) { })

This is not working, I want that second column of row that is 'data1' should be clicked. I need help?

You can rewrite like this :

$('.parent_row').find("td:eq(1)").on("click",function(e){
  //your stuff
})

I tried it out and it worked for me in this way.

You should write click event on td.

$('tr.parent_row td:eq(1)').on('click', function(){
    // handle it here $(this)
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM