Vimal Vimal - 4 months ago 20
HTML Question

How to get any column of any row of a Table in HTML?

Suppose there is Table with variable number of rows of fixed number of columns, and suppose each row has a button too, now I want to select for example a column's value(let's say this selected column is textarea, so I select it's content) when that row's button is clicked.enter image description here

For example in above image I want that if submit is pressed than all data of 'textarea' of corresponding row should be stored in a variable.


You can use the jQuery closest() function to find an element near the clicked button. Add click handlers to the buttons and then traverse up to find the textarea.

    var thisRowsTA = $(this).closest("textarea");