Document.all or document.getlementsByname?

xiaoxiao2021-03-06  68

When the control on the page is the same name and multiple, what do you do first? Judgment length? Indeed, from the rigorous perspective of the program, we need to judge the length, and there are two reference methods for the length and no length. We Come and see: Ole = Document.all.aaa; // Here there is an object of AAA, but we don't know how much it is now, so there is no way to do it. Therefore, we must first determine the process of judging the length. As follows: IF (Ole.length) {} else {}; in two cases, the contents of the curly brackets are also different: if (Ole.Length) {for (var i = 0; i ....< (Div> I want to take all INPUT inside the div, you can write it right: AAA.GETELEMENTSBYTAGNAME ('Input'), which is effective and other DIV (for example, there is a DIV called BBB, the same INPUT is the same. It corresponds to getElementsBytagname, there is document.body.all.tags (), which can be smaller than getElementsBytagname than getElementsBytagname More. But more than getElementsByname. Here we have to mention getElementByid, which is also available only with the Document object, and return is the first element of the array, huh, its method names are written in getElement instead of getElements, so don't worry. Ok, let's get here, take a break, take a break ......

转载请注明原文地址:https://www.9cbs.com/read-91471.html

New Post(0)