JavaScript Question dealing with different browsers

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

    I don't know asp tags. I assume req is a attribute so this should do what you asked by only alerting if the attributes are equal to your requirments, I use a shortcut array to hold all the found elements by tag name as James said its more crossbrowser.

    var a = [];
    a = document.getElementsByTagName("input");
    for(var i=0; i < a.length; i++){
    
    if (theForm.elements[i].getAttribute('type')== "text" &&     theForm.elements[i].getAttribute('req') == "yes" ){
    alert("Made it here wtih" + theForm.elements[i]) 
    }
    } 
    

提交回复
热议问题