querySelectorAll alternative for IE

后端 未结 3 1396
南旧
南旧 2020-12-11 06:28

I\'m running some javascript which uses this:

controls = document.querySelectorAll(\"input,textarea,button\");

It should work on IE 9 (whic

3条回答
  •  渐次进展
    2020-12-11 06:57

    Well, after some search, i ended up using this:

    if( navigator.userAgent.indexOf("MSIE") != -1 ) {                    
       controls = document.getElementsByTagName('input');
    }else{    
       controls = document.querySelectorAll("input,textarea,button");
    }
    

    It works. I'll do some more testing hoping that it will work xD.

提交回复
热议问题