JavaScript Question dealing with different browsers

后端 未结 5 1471
抹茶落季
抹茶落季 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:27

    Use getAttribute to read the custom attributes. See http://jsfiddle.net/8EWQr/.

    So instead of

    (theForm.elements[a].type == "text" && theForm.elements[a].req == "yes")

    use

    (theForm.elements[a].getAttribute('type') == "text" && theForm.elements[a].getAttribute('req') == "yes")

提交回复
热议问题