admin管理员组文章数量:1332361
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;
}
本文标签: phpOnmouseover change color of table rowStack Overflow
版权声明:本文标题:php - Onmouseover change color of table row - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742319252a2452444.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论