• setAttribute 添加属性失效问题


    object.setAttribute(sName, vValue [, iFlags])

    参数:

    sName
    必填项. String类型,属性名

    vValue
    必填项. 为属性指定的变量,可以为string, number, 或者 Boolean类型

    iFlags
    选填. 下面指定的两种 Integer 类型的标志

    0
    覆盖同名属性.

    1
    默认值. 为属性添加指定的值.

    实力

    <html>

    <head runat="server">
        <title>无标题页</title>
        <style type="text/css">
            .TableLine
            {
                border-collapse: collapse;
                border: 1px solid #9BC2E0;
            }
            .TableLine td
            {
                border: 1px solid #9BC2E0;
            }
        </style>

        <script type="text/javascript">
            function a(){
            document.getElementById("td_ID").setAttribute("colspan","2",0); //成功

           //document.getElementById("td_ID").setAttribute("colspan","2"); 失败
      
            }
        </script>

    </head>
    <body onload="a()">
        <form id="form1" runat="server">
        <table id="TableID" class="TableLine">
            <tr>
                <td>
                    1
                </td>
                <td>
                    2
                </td>
            </tr>
            <tr>
                <td id="td_ID">
                    dasfasfd
                </td>
            </tr>
             <tr>
                <td colspan="2">
                    d
                </td>
            </tr>
        </table>
        </form>
    </body>
    </html>

  • 相关阅读:
    前端学习之——h5适配
    Python学习之——【开始】
    前端学习之----隐式类型转换
    前端学习之----数据类型
    vue学习之——生命周期
    认识自己(一)
    判断一句话是否是回文,例如, 上海自来水来自海海上
    判断是否为质数
    Python之函数进阶
    Python之冒泡排序
  • 原文地址:https://www.cnblogs.com/ok519/p/1513128.html
Copyright © 2020-2023  润新知