如何在POPUP中传递表行id

时间:2017-09-09 07:34:18

标签: javascript

如果我点击Addquestion按钮然后弹出打开,该弹出窗口包含相关的测试ID,如何传递相关的id弹出窗口。我附加图像[1]

http://imageshack.com/a/img923/3150/6Hy4tp.png

1 个答案:

答案 0 :(得分:1)

使用jquery你可以轻松地做到这一点。我使用了一个警告来显示id值,同样你可以将这个id值传递给你的popup.Hope它有帮助



$(document).ready(function(){
    $(document).on("click","#Approved",function(){
        var id = $(this).parent().siblings('.ids').text();
        
        alert(id);
       
    });
});

#mytable tr td 
{
border:1px solid black;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="mytable" width="100%" style="border:1px solid;">
<thead  style="border:1px solid;">
<tr>
<th>Test ID</th>
<th>Test Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr class="test">
<td class="ids">11565-GHR </td>
<td class="testName">ASDSDSDSDSD</td>

<td><Button id="Approved" type="submit" >Add Question</button>
</td>

</tr>
<tr class="test">
<td class="ids">144545-ert </td>
<td class="tester">ASDSDSDSDSD</td>

<td><Button id="Approved" type="submit" >Add Question</button>
</td>

</tr>
<tr class="test">
<td class="ids">17878787-erer </td>
<td class="tester">ASDSDSDSDSD</td>

<td><Button id="Approved" type="submit" >Add Question</button>
</td>
</tr>
</tbody>
</table>
&#13;
&#13;
&#13;