Javascript 如何制作整个<;tr>;可在laravel中单击的行?
我试图使整行(tr)在表中可点击。这是我已经厌倦的代码Javascript 如何制作整个<;tr>;可在laravel中单击的行?,javascript,php,laravel,Javascript,Php,Laravel,我试图使整行(tr)在表中可点击。这是我已经厌倦的代码 <table class="container"> <thead> <tr> <th><h1>Id</h1></th> <th><h1>Number</h1></th> <th><h1>Type</h1><
<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>
身份证件
数
类型
价值
@对于($i=0;$i<$count;$i++)
{{$data_数组[$i]['id']}
{{$data_数组[$i]['number']}
{{$data_数组[$i]['name']}
{{$data_数组[$i]['value']}
@结束
`
还有JS脚本
<script type="text/javascript">
$(function () {
$(".container").on("click", "tr[data-url]", function () {
window.location = $(this).data("url");
});
});
</script>
$(函数(){
$(“.container”)。在(“单击”,“tr[data url]”上,函数(){
window.location=$(this.data(“url”);
});
});
它不起作用。请告诉我们怎么做
提前感谢:)
$(函数(){
$('table.container')。在('click','tr.table-tr',function()上{
window.location=$(this.data(“url”);
//警报($(this.data(“url”));
});
});代码>
身份证件
数
类型
价值
身份证件
数
马纳什
28
.on(“click”、“.table tr”)
$(“table.container tbody tr”)。单击(函数(){
谢谢您的建议。它不是工作朋友。我在控制台中也没有任何错误。$(文档)。on(“click”,“tr[data url]”上,函数(){window.location=$(this.data(“url”););我发布了答案这正是你需要的,如果有帮助,请接受答案