Some practical javascript tips _ javascript tips-js tutorial

Source: Internet
Author: User
Summary of some practical javascript skills. If you are interested in learning javascript, you can check it out. Table objects of JS objects (excerpt)

Table object set

Table object: The Table in the HTML document.

Mark, the browser creates a Table object.

Set

Description

Cells [] Returns an array containing all cells in the table.

Js retrieves columns from the row

The Code is as follows:


Var tbodyObj = document. getElementById (tbodyID );
TbodyObj. rows [rowID]. cells [colID]. innerText = "abcd ";
TbodyObj. rows [rowID]. cells [colID]. innerHTML = "abcd
(InnerHTML refers to html code, and innerText refers to the displayed text );



Document.doc umentElement and document. body.
This is the root node root of the body subnode and the entire node tree in the DOMDocument object.

DOM calls every object in a hierarchy a node, which is a hierarchy. You can think of it as a tree structure. Just like our directory, a root directory contains subdirectories, there are also subdirectories under the subdirectory.

Take HTML hypertext markup language as an example: one root of the entire document isIn dom, you can use document.doc umentElement to access it. It is the root node of the entire node tree. The body is a subnode. To access the body tag, write "document. body" in the script.

Understanding of offsetLet, offsetTop, scrollLeft, and scrollTop Methods
Keywords: offsetlet, offsettop, scrollleft, scrolltop
1. offsetTop:
The distance from the current object to the top of the upper layer.
You cannot assign a value to the object. Use the style. top attribute to set the distance from the object to the top of the page.

2. offsetLeft:
The distance from the current object to the left of its upper layer.
You cannot assign a value to the object. Use the style. left attribute to set the distance from the object to the left of the page.

3. offsetWidth:
The width of the current object.
And style. the difference between the width attribute is that, for example, if the width of an object is set to the percentage width, the style is displayed regardless of whether the page is larger or smaller. both width return this percentage, while offsetWidth returns the width value of the object in different pages instead of the percentage value.

4. offsetHeight:
The difference between the style. height attribute and the style. height attribute is as follows:

Knowledge about js iframe operations
1. Print iframe
Eg. frameName.document.exe cCommand ('print ');
2. Get iframe
Eg. var ifr_window = window. frames ["frameName"];
3. Get the element in iframe
Eg1. set the element whose id is elementId in iframe to not display:
Var ifr_window = window. frames ["frameName"];
Ifr_1_elementid.style.display = 'none ';
Eg2. obtain the table whose id is listTable in iframe.
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.