javascript修改元素属性失败
<!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 language="javascript">
function test(i) {
var inputs=document.getElementsByTagName(input);
var edit=inputs[3*i-1];
var upass=inputs[3*i-2];
var uname=inputs[3*i-3];
if(edit.value=='编辑') {
upass.removeAttribute('disabled');
uname.removeAttribute('disabled');
edit.value='保存';
}
else {
upass.setAttribute('disabled','disabled');
uname.setAttribute('disabled','disabled');
edit.value='编辑';
}
}
</script>
</head>
<body>
<table>
<script language="javascript">
for(i=1;i<11;i++) {
document.write("<tr><td><input type='text' disabled='disabled' /><input type='text' disabled='disabled' /><input type='button' value='编辑' onclick='test("+i+")' /></td></tr>");
}
</script>
</table>
<span id="span1"></span>
</body>
</html>
点击按钮后为什么没有修改对应元素属性?
------解决方案--------------------var inputs=document.getElementsByTagName(input);这边的input也不加引号???