javascript - Internet Explorer 中的 onchange

标签 javascript html ajax internet-explorer

为什么我不能在ie中使用onChange? 有没有解决办法?

HTML:

<select id="auto_doors" style="display:none;" name="auto_doors" onchange="updateField(this.value, 'auto_fuel', 5, 6, this.parentNode.id), resetBelow(4,'auto'), show('auto_fuel')">
</select>

功能:

if (jQuery.browser.msie) { setTimeout(DoSomething, 0); } else { DoSomething(); }
        function updateField(str, id, prevvalue, value, vehicletype)
        {
        if (str=="")
          {
          document.getElementById(id).innerHTML="";
          return;
          } 
        if (window.XMLHttpRequest)
          {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
          }
        else
          {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
        xmlhttp.onreadystatechange=function()
          {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
            document.getElementById(id).innerHTML=xmlhttp.responseText;
            }
          }
        xmlhttp.open("GET","inc/form_rest.php?q="+str+"&prevvalue="+prevvalue+"&value="+value+"&vehicletype="+vehicletype,true);
        xmlhttp.send();
        }

最佳答案

尝试将 on on Change 事件绑定(bind)到 auto_doors 元素,如下所示:

$("#auto_doors").change(function(){
   updateField(this.value, 'auto_fuel', 5, 6, this.parentNode.id), resetBelow(4,'auto'), show('auto_fuel');
});

关于javascript - Internet Explorer 中的 onchange,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14676935/

相关文章:

html - css:html 和 body 标签的宽度设置为 100% - 为什么需要这样做?

php - 如何允许跨域文件上传?

javascript - 如何检查文件的类型与其扩展名相同?

javascript - 当回调更新集合时,Angular 2表不刷新,计时器更新刷新整个集合

css - 我应该如何在使用 HTML5 的响应环境中使用 Canvas 连接 SVG?

javascript - 如何使用 Javascript 检测 "on Screenshot"

javascript - 带有 JS 客户端的 REST API

javascript - clearInterval() 无法正常工作

javascript - 在改变 Angular 数组时设置 <tr> 颜色

javascript - 我如何才能对所有依赖项进行版本调整?