JavaScript Question dealing with different browsers

后端 未结 5 1545
抹茶落季
抹茶落季 2021-01-27 13:03

The problem that I\'m having is that my code works fine in JavaScript but doesn\'t work correctly in Firefox or safari and wondering why. What I\'m doing is I have a loop going

5条回答
  •  野性不改
    2021-01-27 13:26

    You should use var theForm = getElementById("theForm") instead of calling theForm directly. Only Chrome and IE adds the elements ids to the javascript global scope.

    And you should use getAttribute() to get the value of an attribute because only IE has this shortcut.

    Try this example.

提交回复
热议问题