I am facing a situation where I have a table with multiple lines as shown below:
<table>
<tr id="line1"><td>Line</td><td>1</td></tr>
<tr id="line2"><td>Line</td><td>2</td></tr>
<tr id="line3"><td>Line</td><td>3</td></tr>
</table>
My objective is to dynamically remove a specific line, for example #line3
, by setting its visibility to collapse using JavaScript:
document.getElementById("line3").style = "visibility:collapse";
One challenge I am facing is that #line3
has a border-top
property defined as follows:
<style>
table {
border-collapse: collapse;
}
#line3 {
border-top:1px solid black;
}
</style>
The issue arises when collapsing #line3
as the border persists, even though the element is hidden. This behavior could be attributed to the border-collapse
property inheriting a border from the previous tr
element. Is there a solution to address this problem?
EDIT: I prefer to retain the existing JavaScript implementation. While removing and re-adding the style element is an option, I am looking for an alternative approach to resolve this issue.