0

我正在尝试将自定义元素添加到 Select html 元素。

 var sel=document.getElementById("sel1");
  sel.setAttribute("customprop","blabla");

在 chrome 中它可以工作,在 IE8 中它没有。

没有查询

4

1 回答 1

2

检查问题:Replace setAttribute with IE compatible script

看来您需要在页面顶部添加 doctype:

<!DOCTYPE html>

然后在您的 head 元素中添加以下标签以使 setAttribute 工作:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
于 2013-11-03T11:41:01.880 回答