2017-05-29 209 views
0

我有一個表格,我想打開同一個tr內部tr點擊加號圖標。我不明白我打開哪個html元素。如何打開tr tr點擊內部tr點擊

請幫我一把。 在此先感謝。

<div class="procedure-table"> 
 
    <table class="table" style="border: 2px slide;"> 
 
     <thead> 
 
      <tr> 
 
       <th>Procedure Name</th> 
 
       <th>Cost</th> 
 
       <th>Taxes</th> 
 
       <th>Notes</th> 
 
      </tr> 
 
     </thead> 
 
     <tbody> 
 
      <tr> 
 
       <td class="proce-td"> 
 
        <ul> 
 
         <li> 
 
          <p>Lorem Ipsum is simply dummy text of the printing and typesetting ghj industry.<span><a href="">[+]</a></span> 
 
          </p> 
 
         </li> 
 
        </ul> 
 
       </td> 
 
       <td class="cost-td">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</td> 
 
       <td class="taxes-td">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</td> 
 
       <td> 
 
        <div class="note-div">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div> 
 
        <i class="material-icons close-icon2">close</i> 
 
        <i class="material-icons edit-icon">edit</i> 
 
       </td> 
 
      </tr> 
 
     </tbody> 
 
    </table> 
 
</div>

+0

謝謝,但我想切換花葯TR不一樣TR。當你點擊圖標相同的tr打開同一個tr –

回答

0

你可以使用近距離圖標。它應該從打開 - >關閉 - >打開 使用jquery觸發事件打開(appendChild或insertAfter)並關閉(removeChild或簡單地刪除)。

jQuery(document).ready(function() { 
 
    jQuery("#plus").click(function() { 
 
     $("#main").append('<tr><td>A</td><td>B</td><td>C</td><td>D</td><td></td></tr>'); 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<table border="1" id="main"> 
 
<tr> 
 
    <td>A</td> 
 
    <td>B</td> 
 
    <td>C</td> 
 
    <td>D</td> 
 
    <td><a href="#" id="plus">[+]</a></td> 
 
</tr> 
 
</table>

+0

先生,你可以給我一個小例子,我是新的jquery。謝謝 –

+0

所以你想有一個副本下面? – David

+0

是的,先生副本tr –

0

你想這樣嗎?

jQuery(document).ready(function() { 
 
\t jQuery(".arrow_btn").click(function() { 
 
\t \t var accor_id = jQuery(this).closest('tr').next('tr').attr("id"); 
 
\t \t var accor_elm = ''; 
 
\t \t accor_elm = "#"+accor_id; 
 
\t \t if (jQuery(accor_elm).is(':visible')) { 
 
\t \t \t jQuery(accor_elm).hide('300'); 
 
\t \t } else { 
 
\t \t \t jQuery(accor_elm).toggle('slow'); 
 
\t \t \t jQuery(".accrdn_class").not(accor_elm).hide('300'); 
 
\t \t } 
 
\t }); \t 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<table class="table"> 
 
<thead> 
 
\t <tr class=""> 
 
\t \t <th>Procedure Name</th> 
 
     <th>Cost</th> 
 
     <th>Taxes</th> 
 
     <th>Notes</th> 
 
\t </tr> 
 
</thead> 
 

 
<tr class="all_con_area"> 
 
\t <td class="arrow_btn">Tester</td> 
 
\t <td class="arrow_btn">Test</td> 
 
\t <td class="arrow_btn"> Design</td> \t \t \t \t \t \t \t \t \t 
 
\t <td class="arrow_img "><a href="#" class="arrow_btn">[+]</a></td> 
 
</tr> 
 
<tr id="satisfication_1" class="accrdn_class" style="display: table-row;"> \t 
 
\t <td colspan="5" class="temonial_cont"><div class="row head_inner_page"> \t \t \t 
 
\t \t <div class="col-md-4 col-sm-4 col-xs-12"> 
 
\t \t \t <table class="table inner_page_table"> 
 
\t   \t <tbody> 
 
\t \t   \t <tr> 
 
\t \t   \t \t <td><p><span>Client Name<span style="float:right;">:&nbsp;&nbsp;</span></span></p></td> 
 
\t \t   \t \t <td ><p>tester</p></td> 
 
\t \t   \t </tr> 
 
\t \t   \t <tr> 
 
\t \t   \t \t <td ><p><span>Company Name<span style="float:right;">:&nbsp;&nbsp;</span></span></p></td> 
 
\t \t   \t \t <td ><p>Test</p></td> 
 
\t \t   \t </tr> 
 
\t \t   \t <tr> 
 
\t \t   \t \t <td ><p><span>Project City<span style="float:right;">:&nbsp;&nbsp;</span></span></p></td> 
 
\t \t   \t \t <td ><p></p></td> 
 
\t \t   \t </tr> 
 
\t \t   \t <tr> 
 
\t \t   \t \t <td ><p><span>Project Name<span style="float:right;">:&nbsp;&nbsp;</span></span></p></td> 
 
\t \t   \t \t <td ><p>Test</p></td> 
 
\t \t   \t </tr> 
 
\t   \t </tbody> 
 
\t   \t </table> 
 
\t \t </div> 
 
\t 
 
    </td> 
 
</tr> 
 
</table>

+0

沒有先生我想要點擊圖標相同的tr在tr下打開。對不起我的英語不好。謝謝 –