为什么select 的name 设不进去? var objectselect=document.createElement("<select name='xxx'>"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var objectselect=document.createElement("select"); objectselect.name="object"; 单纯从这两句来看,是没有错误的,是可以为select 的name属性赋值的,如果出错,可能是别的地方你没写好 元素的name属性是只读的,你可以象1楼那样来创建有name的元素。 我测试是可以赋值的啊<!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></head><body><script type="text/javascript"> var objectselect=document.createElement("select"); objectselect.name='theAddName'; document.body.appendChild(objectselect); alert(objectselect.name); </script></body></html> 楼上的兄弟,是outerHTML打不出来,不过可以投机<!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></head><body><script type="text/javascript"> var objectselect=document.createElement("select"); objectselect.setAttribute("Name",'theAddName'); document.body.appendChild(objectselect); alert(objectselect.outerHTML); </script></body></html> 这里如何做到点击后就提交到数据库asp js var a={}与 var a=new object()有点疑惑请求解答 JS面向对象语法问题 哪位高手能说下js作用域是怎么回事? Javascript中页面之间传值的问题 如何更换图片??谢谢, 帮我解释一下好吗,最好每句都注解一下 如何从一个页面调用执行另一个页面中的Jscript函数? 关于网页在客户端自动下传的问题? 求大佬帮助通过js更换主题背景,要求如下 js如何获得滑动条卷动的值 请教 这两本javascript书籍 哪本更好
objectselect.name="object";
单纯从这两句来看,是没有错误的,是可以为select 的name属性赋值的,如果出错,可能是别的地方你没写好
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<script type="text/javascript">
var objectselect=document.createElement("select");
objectselect.name='theAddName';
document.body.appendChild(objectselect);
alert(objectselect.name);
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<script type="text/javascript">
var objectselect=document.createElement("select");
objectselect.setAttribute("Name",'theAddName');
document.body.appendChild(objectselect);
alert(objectselect.outerHTML);
</script>
</body>
</html>