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.
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.
Share Improve this question asked Jan 8, 2011 at 22:19 sarthaksarthak 2971 gold badge8 silver badges16 bronze badges 2- What have you tried so far? Btw. the code would be much more readable and maintainable if you embed PHP into HTML and not vice versa. – Felix Kling Commented Jan 8, 2011 at 22:22
- Don't echo html, use a templating engine or just use <?=var?>. Your code is very hard to understand. – the_drow Commented Jan 8, 2011 at 22:32
3 Answers
Reset to default 5If you don't need to support IE 6, add this to your CSS:
table tr:hover {
background:orange;
}
Make your <tr>
tags <tr onMouseOver="this.bgColor='#EABF4E';">
, or use table tr:hover
in CSS.
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;
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742319252a4421469.html
评论列表(0条)