select remove option safari 兼容

  select 移除某一 option 的 javascript 公司用的代码是

var ddlPrimaryResource = document.getElementById(ddlPrimaryResourceID);
ddlPrimaryResource.options[ddlPrimaryResource.selectedIndex].remove();

这段代码在 chrome 里执行OK ,但是在 safari 里却报错了

TypeError: 'undefined' is not a function (evaluating 'ddlPrimaryResource.options[ddlPrimaryResource.selectedIndex].remove()')

google 了一下改成

var ddlPrimaryResource = document.getElementById(ddlPrimaryResourceID);
ddlPrimaryResource.removeChild(ddlPrimaryResource.options[ddlPrimaryResource.selectedIndex]);

 

引用:http://www.dyn-web.com/tutorials/forms/select/option/

google 访问不了的可以用这个地址:https://s3-us-west-1.amazonaws.com/google3/index.html

posted on 2014-06-18 09:20  thegavincheng  阅读(487)  评论(0编辑  收藏  举报