Problem:
When writing a dynamic HTML table today, we need to use statistics on the data in td. During the generation, we set the name attribute of td, but document. getElementsByName ("_ test") can obtain this object and print and display the [object] directly, but the length attribute is always 0, no matter how many td names you add, the length obtained by getElementsByName is always 0 !!!
Thanks:
XlingFairy's article: Strange getElementsByName ()
Causes and solutions:
In the original HTML syntax, the td has no name attribute, thanks to the article written by the above-mentioned friend, and he mentioned that if there is no name, getElementsByName will capture the id attribute !! So here I set the td id to "_ test" When dynamically generating the table, and then getElementsByName will get the correct data and print the length. Happy:) Thanks again xlingFairy!