我有一個表格,我想讓用戶點擊表格上的任何元素來獲取數據行。我怎麼做?通過點擊獲取表格行數據
例如,在我看來,我有一張這樣的表。
<table class="myTable">
: <tr class="table">
<th class="table">
Client ID
</th>
<th class="table">
Client Name
</th>
<th class="table">
Client Address
</th>
</tr>
當我運行該項目,我會得到這樣的事情:
如果列客戶名稱的用戶點擊:BBB。它會彈出一個窗口並說:嗨,您已選擇客戶端ID:002,客戶端名稱:BBB,客戶端添加:xxxxx。
用戶可以點擊所有列,它仍然會在彈出窗口中返回整行數據。
如何做到這一點?請幫忙。
HTML: @model IEnumerable @ { ViewBag.Title =「Client」; Layout =「〜/ Views/Shared/_Layout.cshtml」; }
<div class="body">
<div class="outer">
<div class="inner">
<table class="myTable">
<tr class="table">
<th class="table">
Client Name
</th>
<th class="table">
Client Code
</th>
<th class="table">
Client Address
</th>
<th class="searchTable">
Client Lead Partner
</th>
</tr>
@foreach (var i in Model)
{
<tr class="myTable">
<td class="table">@i.ClientName
</td>
<td class="table">@i.ClientCode
</td>
<td class="table">@i.ClientAddress
</td>
</tr>
}
</table>
</div>
</div>
它無關'asp.net-MVC-4'標籤。去爲JQuery或JavaScript。 –
除了表格行中還有其他數據是否要返回,即。你需要從服務器檢索額外的數據嗎? – user1778606
有兩種情況。第一種情況是僅返回表格行中的數據,第二種情況是比較並從服務器檢索附加數據。 – sniggy