js获取表格的行数和列数的方法_javascript技巧

WBOY
Release: 2016-05-16 15:35:21
Original
4464 people have browsed it

如何使用JavaScript获取一个表格的行数和列数?其实很简单,假设存在如下表格:

Copy after login

则获取该表格的行数和列数可分别如下代码:

//表格行数 var rows = document.getElementById("example_table").rows.length; //表格列数 var cells = document.getElementById("example_table").rows.item(0).cells.length;
Copy after login

大家利用以上代码轻而易举的就能通过JavaScript获取表格的行数和列,希望这篇文章对大家的学习有所帮助。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!