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 >
    <table >
        <tr>
            <td>
                1
            </td>
            <td>
                2
            </td>
        </tr>
        <tr>
            <td >
                dasfasfd
            </td>
        </tr>
         <tr>
            <td colspan="2">
                d
            </td>
        </tr>
    </table>
    </form>
</body>
</html>

相关文章:

  • 2021-10-07
  • 2021-07-25
  • 2021-07-28
  • 2021-10-18
  • 2022-12-23
  • 2021-07-25
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2022-02-08
  • 2021-08-08
  • 2021-05-20
  • 2021-11-09
相关资源
相似解决方案