无法显示价值

时间:2011-07-09 11:38:21

标签: javascript jquery

目标:
显示具有属性colspan的行及其值。

问题:
单击“显示”链接后,不知道如何显示行及其值。

// Fullmetalboy


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

        <link rel="stylesheet" type="text/css" href="layout.css" />

        <script src="jquery-1.6.1.js" type="text/javascript"></script>
        <script src="custom.js" type="text/javascript"></script>    
        <title>index</title>

    </head>

    <body>

        <table border="1" SUMMARY="aaa" id="tblProjekt">
          <thead>
            <tr>
              <th>Projekt name</th>
              <th>Total time</th>
              <th>Task</th>
              <th>comments</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>aaa</td>
              <td>aaa</td>
              <td>aaa</td>
              <td>aaa</td>
            </tr>
            <tr>
              <td>aaa</td>
              <td>aaa</td>
              <td>aaa</td>
              <td>aaa</td>
            </tr>
            <tr id="asdf">
                <td colspan="4">bbbb</td>
            </tr>           
            <tr>
              <td>aaa</td>
              <td>aaa</td>
              <td>aaa</td>
              <td>aaa</td>
            </tr>       
          </tbody>
        </table>        

        <a href="" class=submit>display</a>
    </body>
</html>

$(document).ready(init);

function init() 
{
    $("#asdf").hide();

    var tabell = document.getElementById("tblProjekt");
    var newRow = tabell.insertRow(tabell.rows.length);
    var newAttrColspan = document.createAttribute("colspan");
    newAttrColspan.nodeValue = 4;

    newRow.className = "aaa";

    var newCell = newRow.insertCell(0);
    newCell.setAttributeNode(newAttrColspan);
    newCell.innerHTML = "asdf";

    $(".aaa").hide();
}

$('.submit').click(function()
{
    $(".aaa").show();

    $("#asdf").show();

}); // saveForm

1 个答案:

答案 0 :(得分:0)

我修复了它:; - )

<a href="#" class="submit">display</a>

请参阅demonstration fiddle