<input type="text"> 的document.getElementById("").value和document.getElementById("").getAttribute("value")不相同
2012-09-06 18:07
986 查看
<!--产品属性处理部分开始--> <table id="productAttributeBlock" class="tabEditList" style="width:100%;"> <thead> <tr> <th> 属性类型 </th> <th> 属性名称 </th> <th> 属性编码 </th> <th> 是否附加属性 </th> <th> 操作 </th> </tr> </thead> </table> <script type="text/javascript"> var Init = function () { var oTBody = document.createElement('TBODY'); document.getElementById('productAttributeBlock').appendChild(oTBody); }; var AddRow = function (isAdd) { var rowIndex = document.getElementById('productAttributeBlock').tBodies[0].rows.length; var oRow = document.createElement('TR'); oRow.setAttribute("id", "row" + rowIndex); var oUnit = document.createElement('TD'); oUnit.innerHTML = '<input type="text" id="type' + rowIndex + '" name="attributeType"/>'; oRow.appendChild(oUnit); oUnit = document.createElement('TD'); oUnit.innerHTML = '<input type="text" id="name' + rowIndex + '" name="attributeName"/>'; oRow.appendChild(oUnit); oUnit = document.createElement('TD'); oUnit.innerHTML = '<input type="text" id="code' + rowIndex + '" name="attributeCode"/>'; oRow.appendChild(oUnit); oUnit = document.createElement('TD'); oUnit.innerHTML = '<input type="text" id="additional' + rowIndex + '" name="isAdditional"/>'; oRow.appendChild(oUnit); oUnit = document.createElement('TD'); oUnit.innerHTML = '<input type="button" value="添加" id="add' + rowIndex + '" onclick="addFunc()"/>'; oRow.appendChild(oUnit); return oRow; }; var addFunc = function () { //alert(document.getElementById("type0").value); alert(document.getElementById("type0").getAttribute("value")); }; Init(); //AddRow(); if (document.getElementById('productAttributeBlock').tBodies[0].rows.length===0) { document.getElementById('productAttributeBlock').tBodies[0].appendChild(AddRow()); } </script> <!--产品属性处理结束-->
<input type="text"> 的document.getElementById("").value和document.getElementById("").getAttribute("value")不相同:
document.getElementById("").value得到输入值
document.getElementById("").getAttribute("value")得到null
相关文章推荐
- 使用<input type="text" value=<%=str%>>出现取值不全的问题
- Jquery 获得<input type="text" id="test">中的value
- JS获取jQuery获取当前<input type="text" />的value--通过测试了
- html中类似 <input type=“text” name="username[]" value="1">中的方括号的含义
- <input type="text" value="">实现输入提示
- javascript:document.getElementById('<%=this.txtCreateTimeEnd.ClientID %>').value
- IE11也不再支持document.createElement("<input type='file' name='upload'/>");
- <form action="get.php" method="post" id="tform"> <input type="text" name="one"> <a href="jav
- 为什么不能直接通过document.getElementById("<%= txtCard.ClientID %>")
- <input type="text">中的value为null或"",有何区别
- var fGrid = document.getElementById("<%=gvReturnSgd.ClientID %>") 的理解
- jsp页面javascript中用document.getElementById(" ").value无法获取相应text的值
- 使用<input type="text" value=<%=str%>>出现取值不全的问题
- 关于使用 document.getElementById("input").value 给输入域赋值赋不上的问题
- 关于<input type="button" value="搜索">默认样式的清除
- Id.value与document.getElementById("Id").value的区别
- 如何改变<input type=”text" >输入框内的值
- 清空页面上<input type="text" id="inputtext" runat="server">的值的方法
- <input type="button" value="换行" /> Value换行
- 地方浏览器document.getElementById('resForm1_bookTimeStart').value = "${bookTimeStartId}"; var hzfpZldm=$("#hz