am working on an application that reads data from servers that I do not have control over but I need to style the front end on this table to look like the others. the table look
I believe the following function accomplishes what you want by doing:
- Get all the
inside
- Store the
at index 1 (Description)
- Filter the remaining
collection and get the ones that just contain
- If all are empty, remove them and adjust the properties of the remaining
$(function() {
$("table tr").each(function() {
var tds = $(this).find("td"); //find all td
var descriptionTD = tds.eq(1); //get the td for the description
//get the remaining tds that only contain " "
var emptytds = tds.not(descriptionTD).filter(function() {
return $(this).html() === " ";
});
//if all the remaing tds are empty
if (emptytds.length === tds.length - 1) {
emptytds.remove();
descriptionTD.prop("colspan", tds.length).prop("width", "100%");
}
});
});
Date
Description 1
Result
Range
Comments
Description 2
Date
Description 3
Result
Range
Comments
Description 4
讨论(0)
- 热议问题