0

This is my table.

<?php 

while(($result = mysqli_fetch_assoc($query))){
echo  '<tr>';
echo '<td>';
echo $result['serial'];
echo '</td>';
echo '<td>';
echo $result['address'];
echo '</td>';
echo '<td>';
echo '<a href="profile-display.php?name='.$result['name'].'">'.$result['name'].'</a>' ;
echo '</td>';
echo '<td>';
echo $result['postal'];
echo '</td>';
echo '<td>';
echo $result['website'];
echo '</td>';
echo '</tr>';
}

?>

Now I want that if a user moves his mouse over one row, the color should change.

4

3 回答 3

5

If you don't need to support IE 6, add this to your CSS:

table tr:hover {
    background:orange;
}
于 2011-01-08T22:23:57.860 回答
1

Make your <tr> tags <tr onMouseOver="this.bgColor='#EABF4E';">, or use table tr:hover in CSS.

于 2011-01-08T22:25:38.837 回答
1

I am a bit of a noob, but I think you need to give the table row a class, then give that class a hover property in your css file.

Add a class to your table row like so:

echo  '<tr class="highlighter">';

You can name it anything, just make sure you use the same name in your css file.

Now, style the class so that it's color changes when a user's mouse hovers over it:

.highlighter:hover {
    background: #ffff99;
 }
于 2011-01-08T22:29:52.940 回答