【发布时间】:2012-04-17 15:56:38
【问题描述】:
我可以自己破解这个,但我认为 bootstrap 有这个功能。
【问题讨论】:
-
它们已经可以点击了。您希望他们在点击时做某事吗?如果有,是什么?
标签: css html twitter-bootstrap
我可以自己破解这个,但我认为 bootstrap 有这个功能。
【问题讨论】:
标签: css html twitter-bootstrap
使用 jQuery 非常简单。 v2.0 在所有表上使用table 类。
$('.table > tbody > tr').click(function() {
// row was clicked
});
【讨论】:
$('#my_id > tbody > tr')
.on('click', function(){}); 而不是.click
有一个javascript plugin 将此功能添加到引导程序。
当包含rowlink.js 时,您可以:
<table data-link="row">
<tr><td><a href="foo.html">Foo</a></td><td>This is Foo</td></tr>
<tr><td><a href="bar.html">Bar</a></td><td>Bar is good</td></tr>
</table>
表格将被转换,以便可以点击整行而不是只点击第一列。
【讨论】:
bootstrap.css 和jasny-bootstrap.css 并加载jasny-bootstrap.js。 rowlink的使用见jasny.github.io/bootstrap/javascript/#rowlink
该代码将任何设置了data-href 属性的引导表行转换为可点击元素
注意:data-href 属性是有效的 tr 属性 (HTML5),而 tr 元素上的 href 属性则不是。
$(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');
}
);
});
});
【讨论】:
我用模态窗口向你展示我的例子......你创建你的模态并给它一个 id 然后 在您的表格中,您有 tr 部分,只需添加您在下面看到的第一行(不要忘记像这样在第一行设置
<tr onclick="input" data-toggle="modal" href="#the name for my modal windows" >
<td><label>Some value here</label></td>
</tr>
【讨论】:
<tr height="70" onclick="location.href='<%=site_adres2 & urun_adres%>'"
style="cursor:pointer;">
【讨论】:
可能是您在单击表格行时尝试附加一个函数。
var table = document.getElementById("tableId");
var rows = table.getElementsByTagName("tr");
for (i = 0; i < rows.length; i++) {
rows[i].onclick = functioname(); //call the function like this
}
【讨论】:
您可以使用 bootstrap css 以这种方式使用。如果已经分配给任何行,只需删除活动类并重新分配给当前行。
$(".table tr").each(function () {
$(this).attr("class", "");
});
$(this).attr("class", "active");
【讨论】: