bootstrap-table: th - 在左侧添加一个图标
bootstrap-table: th - add on the left an icon
有人知道如何在 bootstrap-table header 的左侧添加内容吗?就像下面的图片一样,我想添加一个图标(问号或其他)成为可点击的 link.
<table id="summaryTable">
<thead>
<tr>
<th data-field="id" data-align="center" data-width="20px" >id</th>
<th data-field="name" data-align="center" data-sortable="true">Name</th>
<th data-field="type" data-align="center" data-sortable="true">type</th>
</tr>
</thead>
</table>
您可以向每个 th
:
添加一个元素
$('#summaryTable thead th').each(function() {
s = $('<span style="position: absolute; left: 4px; top: 8px; cursor: pointer;">?</span>')
s.click(function(e) {
e.stopPropagation();
alert('Question mark clicked')
});
$(this).append(s)
})
Note the e.stopPropagation();
to make sure the clicks on the question mark will not cause also a click on the entire TH
这是你的 jsfiddle 的分支:
https://jsfiddle.net/dekelb/e403uvuh/
有人知道如何在 bootstrap-table header 的左侧添加内容吗?就像下面的图片一样,我想添加一个图标(问号或其他)成为可点击的 link.
<table id="summaryTable">
<thead>
<tr>
<th data-field="id" data-align="center" data-width="20px" >id</th>
<th data-field="name" data-align="center" data-sortable="true">Name</th>
<th data-field="type" data-align="center" data-sortable="true">type</th>
</tr>
</thead>
</table>
您可以向每个 th
:
$('#summaryTable thead th').each(function() {
s = $('<span style="position: absolute; left: 4px; top: 8px; cursor: pointer;">?</span>')
s.click(function(e) {
e.stopPropagation();
alert('Question mark clicked')
});
$(this).append(s)
})
Note the
e.stopPropagation();
to make sure the clicks on the question mark will not cause also a click on the entireTH
这是你的 jsfiddle 的分支:
https://jsfiddle.net/dekelb/e403uvuh/