Http://www.ipuman.com/pm1/s13/152/index.html
In a Web page, IDs are unique, and class can be reused. In some cases, some elements, we use the same class classname to keep them consistent, and when the current end needs to be processed dynamically, we want to be able to get them in class instead of giving them IDs. Here is a JS to get all the same class name elements of the function. View Source print?
01 |
function Getelementsbyclassname (className, Outid) { |
02 |
var Obox = document.getElementById (Outid); Get element with ID Outid |
03 |
THIS.D = Obox | | Document Detects whether a obox exists, and if not, assigns document to internal variables D |
04 |
var children = this.d.getelementsbytagname (' * ') | | document.all; Get all elements of a page |
05 |
var elements = new Array (); Defines an array that is used to store the resulting elements |
06 |
Gets all elements of the element's class as ClassName |