ahm*_*met 1 html javascript jquery
我需要它,所以当你点击一个表行时,它只突出显示表中的一行,如果用户要从同一个表中单击另一个TR,它将取消选择之前选择的TR并突出显示所单击的TR.
救命?
我现在用的是什么
<tr onclick="style.backgroundColor='#eaf0f5';"> ..... </tr>
Run Code Online (Sandbox Code Playgroud)
试试这个:
jQuery 1.7+
$("table tr").on('click', function() {
$("table tr").removeClass("highlight");
$(this).addClass("highlight");
});
Run Code Online (Sandbox Code Playgroud)
jQuery <1.7
$("table tr").click(function() {
$("table tr").removeClass("highlight");
$(this).addClass("highlight");
});
Run Code Online (Sandbox Code Playgroud)
CSS
.highlight { background-color: #FF0; }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
168 次 |
| 最近记录: |