私はいくつかの行を持つテーブルを持ち、各トウはデータキー値を持っています。今度は、これらの行の1つを選択し、このデータ・キー値をGET値として転送するためにボタンをクリックします。私はこの選択されたデータキーをどのようにキャプチャするのか分かりません。親切に助けを求める。ここでボタンをクリックしたときにクリックされたテーブル行のデータキー値を渡す方法
はフィドルです:fiddle以下
は、これまでのところ、私の抜粋です。
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="form-horizontal" style="margin-top:5em;">
<div class="input-group">
<input class="form-control form-control-sm" id="FunctionBookSearchForEvents" placeholder="Search for Events" style="font-size:12px;">
<button class="btn btn-sm btn-secondary" href="events.phtml?TableID=''" data-id="" style="margin-left:1em; font-size:12px;">Add Event</button>
</div>
<div id="Table">
<table class="table table-sm table-hover">
<thead>
<tr>
<th>ID</th>
<th>Event Name</th>
</tr>
</thead>
<tbody>
<tr class="clickable-row" data-key="12">
<td>12</td>
<td>Test Event 12</td>
</tr>
<tr class="clickable-row" data-key="13">
<td>13</td>
<td>Test Event 13</td>
</tr>
</tbody>
</table>
</div>
</div>
しかし、私はそのボタンをクリックし、私のhrefのURLと一緒にデータキーを渡したいと思います。 – Cyber
data-keyは選択した行のIDですか? –
はい、基本的にはすべてのデータキーが一意であるためです。 – Cyber