TD tag -- represents a cell in an HTML table
The TD tag appears in pairs, starting with <TD> and ending with </TD>.
Attribute
Common -- General Attributes
Abbr -- abbreviation of the header
Axis -- conceptual classification of cells
Colspan -- a row that spans multiple columns
Headers -- connect table data and table Header
Rowspan-a column spans multiple rows
Scope -- Define the header of a row or column
Align -- stands for horizontal alignment (left alignment) | center alignment | right (right alignment) | justify (this attribute should be implemented using CSS)
Valign -- specifies the vertical alignment (top alignment) | middle (center alignment) | bottom (bottom alignment) | baseline (baseline alignment) (This attribute should be implemented using CSS)
Obtain the value in <TD> </TD> In Js.
<TD id = "TD1"> </TD>
In JS
Document. getelementbyid ("TD1"). innerhtml = "adfasdf ";
The use of innerhtml attributes is very popular because it provides a simple method to completely replace the content of an HTML element. Another method is to use Dom Level 2 API (removechild, createelement, appendchild ). But obviously, using innerhtml to modify the DOM tree is very easy and effective. However, you need to know that innerhtml has some problems:
When an HTML string contains a script tag marked as defer (<SCRIPT defer>... </SCRIPT>), if the innerhtml attribute is improperly handled, the script injection attack is caused on Internet Explorer.
Setting innerhtml will destroy the HTML elements of the existing registered event handler, and may cause memory leakage in Some browsers.
There are several other secondary disadvantages, which are also worth mentioning:
You cannot get the reference of the created element. You need to manually addCodeTo get those references (using Dom APIs ).
You cannot set the innerhtml attribute on all HTML elements of all browsers (for example, Internet Explorer does not allow you to set the innerhtml attribute on the row element of a table ).