This article describes how to obtain the number of rows and columns of a table through js. For example, if the id attribute value of a table is test, you can use javascript to get the number of rows and columns of the table as follows (compatible with ie and firefox !) :
Var tab = document. getElementById ("test"); // table row var rows = tab. rows. length; // Number of table columns var cells = tab. rows. item (0 ). cells. length; alert ("number of rows" + rows + "Number of columns" + cells );Articles you may be interested in
- Js can only enter numbers and numbers with decimal points, compatible with IE and firefox
- Js shields mouse and keyboard events (including right-click, direction key, backspace key, F5 refresh key, etc.), compatible with IE and firefox
- Js obtains the height of the scroll bar from the top and bottom of the browser. It is compatible with ie and firefox.
- Javascript to get the current mouse position (compatible with IE and firefox)
- Jquery drop-down menu (ultra-simple and practical, compatible with mainstream browsers such as IE and firefox)
- Js to get the current mouse position, compatible with ie and firefox
- Javascript shield right-click, compatible with IE and firefox
- JavaScript to get the number of rows and columns of a table