In current webpage development, the element ID attribute may only be used for searching elements in JavaScript, because it cannot be used repeatedly and violates the CSS coding principles, however, we have recently seen some alternative use.
When learning JavaScript, the method of getting node objects by ID is as follows:
Var idnode = document. getElementById ("idname ")
Then, you can obtain the idnode to change the style:
Idnode. style. color = "# ff0"
But by chance, someone wrote this:
Idname. style. color
My first thought is that writing in this way is definitely wrong. However, the same result as the first method can be obtained! It's too unscientific. If we can get node objects in this simple way, isn't the first method eliminated?
Then I checked some information. The second method is only available in some high-version browsers, with poor compatibility. And does not comply with JS syntax specifications. You can use it for a simple demo. For formal development, use the first method.
Note: getElementById obtains an Object set, that is, [Object].