zoukankan      html  css  js  c++  java
  • <input type="text"> 的document.getElementById("").value和document.getElementById("").getAttribute("value")不相同

     <!--产品属性处理部分开始-->
                   <table id="productAttributeBlock" class="tabEditList" style="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

  • 相关阅读:
    CxImage图像库的使用
    CxImage动态加载图片(判断图片文件类型)
    实现一个类似360的button
    cximage功能简介
    开源图像处理软件代码
    MFC + CxImage 实现自绘半透明按钮
    VC 下加载 JPG / JPEG / GIF / PNG 图片最简单的方法
    时序数据库InfluxDB:简介及安装
    学习springboot整合mybatis并编写测试类
    Mybatis-Plus使用全解
  • 原文地址:https://www.cnblogs.com/hongjiumu/p/2673968.html
Copyright © 2011-2022 走看看