разверните строку таблицы с помощью jquery

0

У меня есть таблица со значениями при нажатии любой из строки я должен показать result значение passed or failed

вот код, который я использую из этого кода, как я могу создать расширяемую строку

function testHistory() {
    $.ajax({
        url: '/getJobs',
        cache: false
    }).done(function (report) {
        report = report.reverse();
        var testhistbl = '<br><table class="tablestyle" cellspacing="10" width="400px"><tr><th  class="thstyle" valign="center">User</th><th class="thstyle" valign="center" >Test Name</th><th  class="thstyle" valign="center">VM</th><th  class="thstyle" valign="center">Browsers</th><th  class="thstyle" valign="center">Result</th></tr>';
        report.forEach(function (result) {
            testpassfail(result.id, function (passfail) {
                testhistbl += '<tr><td class="rstyle">' + result.email + '</td><td class="rstyle">' + result.names + ' </td><td class="rstyle">' + result.os + '</td><td class="rstyle">' + result.browser + '</td><td class="rstyle">' + passfail + ' </td></tr>';
            });
        })
        testhistbl += '</table>';
        $('#testhistyTbl').html(testhistbl);
    });
}

мой hrml-код

<table class="tablestyle" width="400px" cellspacing="10">
    <tbody>
      <tr>
        <th class="thstyle" valign="center">User</th>
        <th class="thstyle" valign="center">Test Name</th>
        <th class="thstyle" valign="center">VM</th>
        <th class="thstyle" valign="center">Browsers</th>
        <th class="thstyle" valign="center">Result</th>
      </tr>
      <tr>
        <td class="rstyle">[email protected]</td>
        <td class="rstyle">kkk</td>
        <td class="rstyle">VM-WIN7-64</td>
        <td class="rstyle">FF,GC</td>
        <td class="rstyle"><span class="pass"><b><font color="green">Passed<b></b></font></b></span><b><font color="green"><b> </b>
          </font>
          </b>
        </td>
      </tr>
      <tr>
        <td class="rstyle">Guest</td>
        <td class="rstyle">ttutu</td>
        <td class="rstyle">VM-WIN7-64</td>
        <td class="rstyle">FF,IE</td>
        <td class="rstyle"><span class="fail"><b><font color="red">Failed</font></b></span>
          <font
          color="red"></font>
        </td>
      </tr> 
    </tbody>
</table>
  • 0
    в чем проблема тогда? пожалуйста, укажите ваш HTML тоже
  • 0
    я отредактировал свой HTML-код
Показать ещё 3 комментария
Теги:
html-table

1 ответ

0

попробуйте этот код. Вместо .html() используйте метод append()

$.ajax({
        url: '/getJobs',
        cache: false
    }).done(function (report) {
        report = report.reverse();
        report.forEach(function (result) {
         var trElement = $("<tr/>");
         trElement.append($('<td/>', { html: result.email }));
        trElement.append($('<td/>', { html: result.names }));
        trElement.append($('<td/>', { html: result.os }));
        trElement.append($('<td/>', { html: result.browser }));
        trElement.append($('<td/>', { html: passfail }));
        $("#testhistyTbl").append(trElement);  
            });
        })
    });

Ещё вопросы

Сообщество Overcoder
Наверх
Меню