admin管理员组文章数量:1306063
I have following table structure
<table>
<tbody>
<tr>
<td>Lorem</td> <td>Ipsum</td> <td>Fierent</td>
</tr>
<tr>
<td>Lorem ipsum</td> <td>pro ut tale erant</td> <td>mnesarchum ne</td>
</tr>
<tr>
<td >mnesarchum ne </td> <td >sapientem</td> <td >fierent mnesarchum </td>
</tr>
</tbody>
</table>
Now, I want to highlight the row, on which mouse is hovering? So, I have 2 questions:
- How can I achieve highlight row affect on above mentioned table structure?
- How can I revert back the highlight effect, when row don't have move hovering over it?
I am using jQuery 1.4+, so please suggest me way to achieve the following using jQuery code.
I have create jsfiddle for the same: /
Thanks.
I have following table structure
<table>
<tbody>
<tr>
<td>Lorem</td> <td>Ipsum</td> <td>Fierent</td>
</tr>
<tr>
<td>Lorem ipsum</td> <td>pro ut tale erant</td> <td>mnesarchum ne</td>
</tr>
<tr>
<td >mnesarchum ne </td> <td >sapientem</td> <td >fierent mnesarchum </td>
</tr>
</tbody>
</table>
Now, I want to highlight the row, on which mouse is hovering? So, I have 2 questions:
- How can I achieve highlight row affect on above mentioned table structure?
- How can I revert back the highlight effect, when row don't have move hovering over it?
I am using jQuery 1.4+, so please suggest me way to achieve the following using jQuery code.
I have create jsfiddle for the same: http://jsfiddle/c9h5w/
Thanks.
Share Improve this question edited Apr 14, 2011 at 9:40 Aron Rotteveel 83.2k17 gold badges105 silver badges129 bronze badges asked Apr 14, 2011 at 9:26 I-M-JMI-M-JM 16k26 gold badges79 silver badges105 bronze badges2 Answers
Reset to default 7I'd add a classname to the row that is currently being hovered. You can then use CSS to style every table cell within this row with a certain background color, for example. Removing the styling is simply a matter of triggering a mouseout
event and removing the classname.
CSS:
.hovered td {
background: #ddd;
}
JavaScript:
$('table tr').mouseover(function() {
$(this).addClass('hovered');
}).mouseout(function() {
$(this).removeClass('hovered');
});
Live example.
Check-it Out:
$("table tr").hover(
function(){
$(this).css("background-color","#FFEFC6");
//$(this).addClass('className'); //if ur working with class
},
function(){
$(this).css("background-color","");
//$(this).removeClass('className'); //if ur working with class
}
);
CLICK HERE TO SEE THE DEMO
本文标签: javascripthighlight table rowStack Overflow
版权声明:本文标题:javascript - highlight table row - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741812461a2398879.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论