请问,是否可以使用 JQuery 在悬停时向表格的 tr 添加边框?
我的意思是,
$("#table tr").hover(function()
{
$(this).css("border","1px solid #6da8dc");
$("#doc_options").show();
},function()
{
$(this).css("border","none");
$("#doc_options").hide();
});
如果这可行,我该如何创建在每个 tr 上设置的 1px 不可见边框,以便当我悬停时,tr 不会跳跃,因为刚刚添加了 1px 边框。
最佳答案
我同意@David Dorward 的观点,您实际上并不需要 jQuery。但是假设你想做一些更复杂的事情,比如淡入 "#doc_options"
,这应该让你开始:
$("#table tr").hover(function() {
$(this).addClass('trHover');
$("#doc_options").show();
}, function() {
$(this).removeClass('trHover');
$("#doc_options").hide();
});
CSS:
#doc_options {
display: none
}
#table tr {
border: 1px solid transparent
}
#table .trHover {
border: 1px solid #6da8dc
}
关于jquery - 使用 JQuery 在悬停时向表格的 tr 添加边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5143413/