input.setAttribute('类型', '复选框'); IE错误
此问题仅在 ie 中出现。所有其他浏览器即 ff、chrome、safari、opera 都运行良好。 它不显示 chcekbox 而是显示一个值框...
代码:
<html>
<head>
<title></title>
<style>
*{margin:0;padding:0;}
ul {
padding:10px 10px 0 35px;
list-style:none;
}
li{
display:inline;
text-weight:bold;
color:#475D7F;
}
li img{margin-bottom:-2%;}
</style>
<script language="JavaScript" type="text/javascript">
<!--
function DOM(obj,id){
var total=10;
var coll=3;
var row=total/coll;
var tar=document.getElementById(id);
var table=document.createElement('TABLE');
table.border='0';
tar.appendChild(table);
var tbdy=document.createElement('TBODY');
table.appendChild(tbdy);
for (var zx1=0;zx1<=row;zx1++){
var tr=document.createElement('TR');
tbdy.appendChild(tr);
for (var zx2=0;zx2<coll;zx2++){
var td=document.createElement('TD');
var ul=document.createElement('UL');
var input=document.createElement('INPUT');
var img=document.createElement('IMG');
tr.appendChild(td);
td.width='200';
td.appendChild(ul);
var li1=document.createElement('LI');
li1.appendChild(input);
ul.appendChild(li1);
input.setAttribute("name", "friend");
***input.setAttribute('Type', 'checkbox');***
input.setAttribute("value", "yap frnd");
input.setAttribute("id", "xyz");
var li2=document.createElement('LI');
ul.appendChild(li2);
li2.appendChild(img);
img.setAttribute("src", "x.jpg");
img.setAttribute("title", "x");
img.setAttribute("alt", "x");
img.setAttribute("style", "padding-bottom:-2%;");
var li3=document.createElement('LI');
ul.appendChild(li3);
li3.appendChild(document.createTextNode('Ataus Samad Rubel'));
}
}
}
//-->
</script>
</head>
<body>
<select onchange="DOM(this,'target');" >
<option >DOM Method</option>
<option >do</option>
</select>
</body>
</html>
希望有人研究它..感谢您的赞赏。
This problem shows only in ie.all other browser namely ff,chrome,safari,opera works well.
It doesn't show chcekbox instead shows a value box...
code:
<html>
<head>
<title></title>
<style>
*{margin:0;padding:0;}
ul {
padding:10px 10px 0 35px;
list-style:none;
}
li{
display:inline;
text-weight:bold;
color:#475D7F;
}
li img{margin-bottom:-2%;}
</style>
<script language="JavaScript" type="text/javascript">
<!--
function DOM(obj,id){
var total=10;
var coll=3;
var row=total/coll;
var tar=document.getElementById(id);
var table=document.createElement('TABLE');
table.border='0';
tar.appendChild(table);
var tbdy=document.createElement('TBODY');
table.appendChild(tbdy);
for (var zx1=0;zx1<=row;zx1++){
var tr=document.createElement('TR');
tbdy.appendChild(tr);
for (var zx2=0;zx2<coll;zx2++){
var td=document.createElement('TD');
var ul=document.createElement('UL');
var input=document.createElement('INPUT');
var img=document.createElement('IMG');
tr.appendChild(td);
td.width='200';
td.appendChild(ul);
var li1=document.createElement('LI');
li1.appendChild(input);
ul.appendChild(li1);
input.setAttribute("name", "friend");
***input.setAttribute('Type', 'checkbox');***
input.setAttribute("value", "yap frnd");
input.setAttribute("id", "xyz");
var li2=document.createElement('LI');
ul.appendChild(li2);
li2.appendChild(img);
img.setAttribute("src", "x.jpg");
img.setAttribute("title", "x");
img.setAttribute("alt", "x");
img.setAttribute("style", "padding-bottom:-2%;");
var li3=document.createElement('LI');
ul.appendChild(li3);
li3.appendChild(document.createTextNode('Ataus Samad Rubel'));
}
}
}
//-->
</script>
</head>
<body>
<select onchange="DOM(this,'target');" >
<option >DOM Method</option>
<option >do</option>
</select>
</body>
</html>
wish someone look into it..thanks for your appreciation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 IE 中将
或
You can't change the
type
attribute of an<input>
or<button>
after adding it to the DOM in IE, so change it before appending it, like this:尝试:
注意小写的
t
。try:
Notice the lowercase
t
.由于 IE 不支持在分配输入类型后对其进行更改,您应该在将类型添加到 DOM 之前分配类型。
Since IE doesn't support a change in an input type once it has been assigned, you should assign the type before adding it to the DOM.