Reputation: 113
I am doing a webapp and I have a table which is generated by wicket ListView. What the app does is that when the mouse hovers over a cell, the app will populate an info panel via ajax and what I want is to change cell border so that the user can know which cell the information is related to. currently I have the following code in css. (scroll-content-item is the class of the table)
scroll-content-item td:hover{
border-style:outset;
border-width:5px;
border-color:#0000ff;}
This does give the border on hover but as soon as the user move the mouse outside the cell the border is gone. What I want is a way to make the border stay as long as the mouse doesn't move to another cell. Is there any way to make the border stay until the mouse is moved onto another cell? I appreciate any suggestions.
Upvotes: 0
Views: 3476
Reputation: 276
table {
border-collapse: collapse;
}
td {
border-top: 1px solid black;
border-left: 1px solid black;
border-right: none;
border-bottom: none;
}
tr td:last-child {
border-right: 1px solid black;
}
tr:last-child td {
border-bottom: 1px solid black;
}
td:hover {
border: 1px solid red !important;
}
Upvotes: 0
Reputation: 113
This is my final solution:
<!DOCTYPE HTML>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style>
.highlight{
border-style:outset;
border-width:3px;
border-color:#0000ff;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("td").hover(function(){
$("td").removeClass('highlight');
$(this).addClass('highlight');
});
});
</script>
</head>
<body>
<table class="waypointsTable" border="1">
<tbody>
<tr>
<td>some text</td>
<td>some text</td>
<td>some text</td>
<td>some text</td>
</tr>
</tbody>
</table>
</body>
</html>
Upvotes: 0