gpt4 book ai didi

javascript - 大多数表单 javascript 使用 ID 而不是 NAME 的原因

转载 作者:太空狗 更新时间:2023-10-29 16:01:46 24 4
gpt4 key购买 nike

<分区>

有人可以深入了解使用 NAME 与表单元素交互的历史/原因已经过时,而 document.getElementById 已接管。

究竟是什么历史事件促使了这种变化和转变。

最后,是否发生了转变,或者两者仍然是推荐的做事方式?

Document.getElementById vs  document.form.name

根据一些论坛讨论,document.form.name 并非被所有浏览器识别。是这样吗?见:

"I've been told in the past that you should not use "document.form_name.element_name" compared to "document.getElementById()", as the first is not recognized by all browsers. "

24 4 0