手风琴表js

问题描述

我有这段代码,可以让我从sql数据库获取数据。

代码表:

dumb\n10001\n16\ngirl\nABC\n1002\n56\nboy\n

我无法在页面底部获取js脚本来使用代码

dumb\n10001\n16\ngirl\nABC\n1002\n56\nboy\nrl\nABC\n1002\n56\nboy

代码JS:

{
  "source": [
    "aws.sts"
  ],"detail-type": [
    "AWS API Call via CloudTrail"
  ],"detail": {
    "eventSource": [
      "sts.amazonaws.com"
    ],"eventName": [
      "AssumeRoleWithWebIdentity"
    ]
  }
}

它返回我“未定义”

解决方法

为了测试,我已经将PHP转换为HTML。

检查此代码段。我选择了要显示红色的行。

但是必须找到正确的行: $('#id_tabella tr.view').last()

var lastRow = $('#id_tabella tr').last();
lastRow.css('background','red'); // TEST which row we found

var ultimo = lastRow.attr("Id");
console.log(ultimo);

// Now make a correction
lastRow = $('#id_tabella tr.view').last();
ultimo = lastRow.attr("Id");
console.log(ultimo); // Now Good!
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<table id="id_tabella" class="fold-table" align="center" style="margin-bottom:40px">
  <thead>
    <tr>
      <th style="">Id</th>
      <th>OrderCode</th>
      <th>Partner</th>
      <th>NrProdotti</th>
      <th>Totale</th>
      <th>Stato</th>
    </tr>
  </thead>
  <tbody>
    <tr id="id1" class="view">
      <td style="">id1</td>
      <td>OrderCode</td>
      <td><img align="middle" src="#" width="10%"></td>
      <td>NrProdotti</td>
      <td>TotaleOrdine</td>
      <td>
        <form method="POST" action="">
          <input name="idOrdine" value="id1" type="submit">
        </form>
      </td>
    </tr>
    <tr class="fold">
      <td colspan="6">
        <div class="fold-content">
          <h3>DETTAGLIO ORDINE</h3>
          <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
          <table>
            <thead>
              <tr>
                <th>Dettaglio Ordine:</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>XXX
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </td>
    </tr>
  </tbody>

因此在您的代码中,您发现了实际上是这一行的“最后”行:

<td>
                                               <?php
                                               $data = json_decode($result['JsonOrdine'],true);
                                               foreach($data['products'] as $key=>$val){
                                                    echo '<b>'.$val['name'].' * '.$val['quantity'].'</b><br>';
                                                    foreach($val['attributes'] as $keys=>$value){
                                                            echo $value['name'].' * '.$value['quantity'].'<br>';
                                                    }
                                               }
                                               ?>
                                            </td>

因此,请尝试将搜索更改为:

var ultimo = $('#id_tabella tr.view').last().attr("Id");