Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #17971
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2013-01-05 16:20 -0800 |
| References | <2fa3ab54-c5d2-492a-8c95-9ee10fa6a611@googlegroups.com> <78402d0d-6ffd-4340-81c5-ac07a74f9eeb@googlegroups.com> |
| Message-ID | <0285461a-0b00-48db-bc20-d440f1291ca4@googlegroups.com> (permalink) |
| Subject | Re: count table rows |
| From | Luc Yen <luc@goal.tw> |
jr於 2012年12月8日星期六UTC+8上午3時40分38秒寫道:
> On Friday, December 7, 2012 10:27:48 AM UTC-8, jr wrote:
>
> The error in firefox is:
>
> TypeError: document.getElementById("table") is null
After closing and properly nesting the original markup, it works as expected.
Not a script problem.
-----
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>To-Dos</title>
</head>
<body>
<table id="table">
<tr>
<td> this</td> <td> is</td> <td> a test</td>
</tr>
<td>of</td><td> counting<td>table</td><td>rows</td>
</tr>
</table>
<script type="text/javascript">
window.addEventListener("load",
function(){
var todocount = document.getElementById('table').rows.length;
console.log(todocount);
mydiv = document.getElementById("todocount");
mydiv.innerHTML = todocount;
},false);
</script>
<div id="todocount"></div>
</body>
</html>
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
count table rows jr <jlrough@yahoo.com> - 2012-12-07 10:27 -0800
Re: count table rows Stefan Weiss <krewecherl@gmail.com> - 2012-12-07 19:48 +0100
Re: count table rows "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-12-07 20:56 +0200
Re: count table rows jr <jlrough@yahoo.com> - 2012-12-07 11:23 -0800
Re: count table rows "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-12-07 21:38 +0200
Re: count table rows jr <jlrough@yahoo.com> - 2012-12-07 13:10 -0800
Re: count table rows Christoph Becker <cmbecker69@gmx.de> - 2012-12-07 21:44 +0100
Re: count table rows jr <jlrough@yahoo.com> - 2012-12-07 12:57 -0800
Re: count table rows jr <jlrough@yahoo.com> - 2012-12-07 13:08 -0800
Re: count table rows Christoph Becker <cmbecker69@gmx.de> - 2012-12-07 22:56 +0100
Re: count table rows JRough <janis.rough@gmail.com> - 2012-12-07 16:28 -0800
Re: count table rows Christoph Becker <cmbecker69@gmx.de> - 2012-12-08 03:12 +0100
Re: count table rows jr <jlrough@yahoo.com> - 2012-12-07 11:40 -0800
Re: count table rows Luc Yen <luc@goal.tw> - 2013-01-05 16:20 -0800
Re: count table rows Dr J R Stockton <reply1249@merlyn.demon.co.uk.invalid> - 2012-12-09 16:37 +0000
Re: count table rows Matt McDonald <matt@fortybelow.ca> - 2012-12-13 11:41 -0500
csiph-web