0

私はこのようなテーブルを持っています:

<table id=reportTbl>
  <tbody>
    <tr>
      <td>
        <table id=list>
          <tbody>
            <tr>
              <td>
                <a title="View Report" onclick="viewReport(123);"><img src="../images/report/icon_pdf.gif" border="0"></a>
              </td>
              <td>Customer Orders</td>
              <td>USA</td>
              <td>Jul 20 2012 3:32PM</td>
            </tr>
            .....

          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

#listテーブルのテーブル行全体をクリックできるようにしたい。追加しようと思った

$('#reportTbl #list a').each( function() {
  // I have other code in this section 
  // ....
  // end other section     

  $(this).closest('tr').click( function() { $(this).find('a[title="View Report"]').click(); });
});

しかし、行をクリックすると、#listテーブル内のすべてのリンクのウィンドウが開き続けます。さまざまな種類のjQuery呼び出しを試しましたが、それらはすべて同じことを行います。

4

1 に答える 1

3
$('#list').on('click', 'tr', function(e) {

    if ( e.target.tagName.toLowerCase() !== 'a' ) {

        $('a[title="View Report"]', this).click();
    }
});​
于 2012-07-30T19:51:37.477 に答える