我正在嘗試使表中的整行(tr)可點擊。下面是代碼我已經厭倦了,如何使整個<tr>行在laravel中可點擊?
<table class="container">
<thead>
<tr>
<th><h1>Id</h1></th>
<th><h1>Number</h1></th>
<th><h1>Type</h1></th>
<th><h1>Value</h1></th>
</tr>
</thead>
<tbody>
@for ($i = 0; $i < $count; $i++)
<tr class="table-tr" data-url="http://www.engineering.us/gena/details.php">
<td>{{ $data_array[$i]['id'] }}</td>
<td>{{ $data_array[$i]['number'] }}</td>
<td>{{ $data_array[$i]['name'] }}</td>
<td>{{ $data_array[$i]['value'] }}</td>
</tr>
@endfor
</tbody>
`
而且JS腳本,
<script type="text/javascript">
$(function() {
$(".container").on("click", "tr[data-url]", function() {
window.location = $(this).data("url");
});
});
</script>
這是行不通的。請告訴我們如何做到這一點。
感謝提前:)
'。對( 「點擊」, 「表-TR」)'? –
'$(「table.container tbody tr」)。click(function(){' –
感謝您的建議,它不是在工作的朋友,我在控制檯也沒有任何錯誤 – Haripriya