How should i get the only invoice id from the table which checkbox is checked? I need the jquery code in between which is checked the checkbox is checked or not? This is my coode of jquery
$(document).on("click",".contactsepa",function(){
var table = $("table tbody");
table.find('tr').each(function (i) {
var $tds = $(this).find('td'),
invoiceid = $tds.eq(2).text();
// do something with invoiceid
alert('Row ' + (i + 1) + ':\ninvoiceId: ' + invoiceid);
});
});
Here is the screenshot in which i want to get the redbox value
I understand you want to fetch only the "tr" with the checkbox checked. So you have to modify your jQuery selector to get only those "tr".
It will lead you to something like :
// Get all the checked inputs then return their "tr" parents.
var checkedLines = $("table tbody input[:checked]").parents("tr");
With the help of JBO and some searching i have got success to fetch the value. Here is the code if anything stuck like that.
$(document).on("click","#sepacreatebtn",function(){
var table = $('table tbody input[name = "invoicearr[]"]:checked');
table.parents('tr').each(function (i) {
var $tds = $(this).find('td'),
invoiceid = $tds.eq(2).text();
if(invoiceid){
console.log('Row ' + (i + 1) + ':\ninvoiceId: ' + invoiceid);
}
});
});
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.