JS修改input类型的问题,纠结的我。。。抓头 ie中input的type是初始化时必须指定的而且不能更改 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先将它用一个div包裹起来,记录input的值,重写div的innerHTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">function change(a){ var text=document.getElementById("test"); if(a.checked){ try{ text.type='hidden'; }catch(e){ var p=text.parentNode; var hiden=document.createElement("input"); hiden.type='hidden'; p.replaceChild(hiden,text); hiden.setAttribute('id','test'); } }else{ try{ text.type='text'; }catch(e){ var p=text.parentNode; var hiden=document.createElement("input"); hiden.type='text'; p.replaceChild(hiden,text); hiden.setAttribute('id','test'); } }}</script></head><body><input type="text" id="test" /><input type="checkbox" name='ss' onclick="change(this)"></body></html>ie是不能修改type属性的 或者直接设置display属性试试 JavaScript如何关闭IE浏览器? 急!在线等 点击链接之后,2秒再进入页面的问题~ 欢迎关注 javascript有没有什么方法可以检查连接状态? window.returnValue 的问题???着急啊 关于"+"的使用,字符相加,数字相加? 高分求javascript完整对象手册,谢谢 紧急求助:如何知道obj1是某对象阵列的元素,不要用遍历 关于页面打开和关闭的问题? javascript去两端空格的方法是什么???? 正则表达式/.../i,最后那个i用来干什么的? 两段JS代码好像起了冲突,我是外行,请问解决方法。 怎么排除数组里面的重复数字啊?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function change(a){
var text=document.getElementById("test");
if(a.checked){
try{
text.type='hidden';
}catch(e){
var p=text.parentNode;
var hiden=document.createElement("input");
hiden.type='hidden';
p.replaceChild(hiden,text);
hiden.setAttribute('id','test');
}
}else{
try{
text.type='text';
}catch(e){
var p=text.parentNode;
var hiden=document.createElement("input");
hiden.type='text';
p.replaceChild(hiden,text);
hiden.setAttribute('id','test');
}
}
}
</script>
</head><body>
<input type="text" id="test" />
<input type="checkbox" name='ss' onclick="change(this)">
</body>
</html>
ie是不能修改type属性的
或者直接设置display属性试试