【发布时间】:2020-09-16 17:18:17
【问题描述】:
我正在使用 bootstrap 4 并获得了一个表格,其中表格行是可点击的。每行还有两个按钮。但是按钮不再起作用,因为它正在执行单击行所做的任何事情。
这是一个示例表
<table id="subjects" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th class="d-none">IDs</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr data-href="subjects/blah">
<td nowrap class="d-none">
<div>121212</div>
</td>
<td>
<button type="button" class="btn btn-dark" onclick="location.href='subject/fff'">Edit</button>
<button type="button" class="btn btn-dark" data-toggle="modal" data-target="#confirm-delete" data-href="subject/delete/blah">Delete</button>
</td>
</tr>
</tbody>
</table>
<script>
$(document).ready(function() {
$('.table tr[data-href]').each(function(){
$(this).css('cursor','pointer').hover(
function(){
$(this).addClass('active');
},
function(){
$(this).removeClass('active');
}).click( function(){
document.location = $(this).attr('data-href');
}
);
});
});
</script>
第一个按钮有一个 onclick,第二个按钮打开一个引导模式对话框。
目前,在我删除表格行 jquery 单击功能之前,这些按钮都不起作用。我怎样才能让它很好地工作?
【问题讨论】:
-
我认为这是您的解决方案:stackoverflow.com/questions/31921334/…
-
你是对的!这确实对我有帮助,并且与我遇到的问题相同。谢谢。如果你想发帖,我可以接受作为答案
-
我认为这是您的解决方案:stackoverflow.com/questions/31921334/…
标签: jquery asp.net-mvc bootstrap-4