You cannot do it the way you are trying. If you look at the table with all the borders, you will clearly see that a border only belongs to the
<table>
element or to the cell elements (
<td>
,
<th>
).
If some borders has to be hidden and then shown, create two different CSS styles and toggle them. If you want to toggle cell elements, you have to get a set of them in a row, and toggle the CSS class for the whole set.
For example, you can write this
td
classes in your CSS:
td { border: solid red; }
td.visibleBorder { border-width: 2px; }
td.hiddenBorder { border-width: 0; }
You can toggle between classes "visibleBorder" and "hiddenBorder". This is a very simplified sample, just to illustrate the idea. Rather, you should separately set the properties
border-left
,
border-top
, and so on.
One convenient way to do that is using jQuery:
http://api.jquery.com/toggleclass[^],
see also http://api.jquery.com/category/css[^].
Also, jQuery allows you to get an object wrapper representing the whole set of elements chosen by some set of attributes: id, content, order, class and so on: http://api.jquery.com/category/selectors[^].
[EDIT]
So, the idea is to operate cell's properties instead of the row, because it's the cell carries the row's borders.
With
WebBrowser
control, you can, for example, manipulate border colors to make border invisible/transparent. See the
IHTMLTableCell.border*
properties:
https://msdn.microsoft.com/en-us/library/aa741764%28v=vs.85%29.aspx[
^]
Another approach it to rewrite the whole document or some of its DOM nodes style node. I'm not sure if you need to show and hide some borders dynamically. More usually, the document is formed just once once. But if it has to be dynamic, you can 1) in first place, predefine "hidden" and "visible" classes for the table cells, and modify the set of cell objects, changing its CSS class; this way, CSS
<style>
node content remains the same at all times; 2) keep the classes in the cell nodes, but change the classes themselves by replacing the whole
<style>
node of the document. It depends on you goals and preferences. To do so, you need to do DOM manipulations.
[END EDIT]
—SA