当我实现此代码时 - 复选框的名称将不会显示在浏览器旁边的复选框 - 只是复选框本身。这是什么原因?我是否错误地使用setattribute-function?Javascript setattribute - 名称和值不起作用
<script type="text/javascript">
var x = document.createElement("INPUT");
x.setAttribute("type", "checkbox");
x.setAttribute("value", "car");
x.setAttribute("name", "vehicle");
document.body.appendChild(x);
</script>
代码工作罚款:https://jsfiddle.net/ag663kw8/'name'不会在您的''旁边添加文字'车辆';这就是'
您是否尝试添加标签? – Ygalbel