php - How to find selected value of upper row of a table with jquery? -
i have table this. , rows of table loop php. want option value of upper row when user click option value next row of table. mean is, if click option row number 3, want option value of row number 2. so, try this.
$("select[name='service[]']").change(function(event){ console.log("row"+$("table[name='tbl_list'] tr:last").prev().index()); });
but row14
every row clicked. so, how can user selected option value of upper row when click option next row?
use closest parent row , prev previous row
$("select[name='service[]']").change(function(event) { var val = $(this).closest("tr").prev('tr').find("option:selected").val(); });
Comments
Post a Comment