About the value of the TD tag in JSP

Source: Internet
Author: User

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 ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.