document.getElementById(“selAge”) Vs document.myForms.selAge

后端 未结 4 2023
予麋鹿
予麋鹿 2020-12-22 04:05

What is difference between

document.getElementById(“selAge”) 
document.myForms.selAge

When to use which?

4条回答
  •  半阙折子戏
    2020-12-22 04:48

    They are two different paths to the same goal, which one you use depends on your preference. Personally I would use document.getElementById(“selAge”) because if the structure of your HTML changes then it would still work.

提交回复
热议问题