javascript - coloring a td on mouse hover - Stack Overflow

I want to add a background color on a td as a mouse hover in smarty.How can I use create a hover I made

I want to add a background color on a td as a mouse hover in smarty.

How can I use create a hover I made a class for hover but its not working.

Help me out

I want to add a background color on a td as a mouse hover in smarty.

How can I use create a hover I made a class for hover but its not working.

Help me out

Share Improve this question edited Feb 21, 2011 at 8:18 Hussein 42.8k25 gold badges115 silver badges143 bronze badges asked Feb 21, 2011 at 5:42 SunnySunny 51 silver badge4 bronze badges 1
  • Can you show us what you tried that is not working? – Muhammad Akhtar Commented Feb 21, 2011 at 5:44
Add a ment  | 

4 Answers 4

Reset to default 7

see the css :hover selector.

In your case:

td.yourClass { background-color: transparent; }
td.yourClass:hover { background-color: red; /* for example */ }

Live demo

<SCRIPT language="JavaScript">
function rollbg(chosen, objectID) {
if(chosen == "roll") {
document.getElementById(objectID).className="roll";
}
else {
document.getElementById(objectID).className="over";
}
}
</SCRIPT>




    <STYLE>

.hlink {
display block;
height:20px;
width:75px;
color:black;
background-color:white;
text-align:center;
text-decoration:none;
}
.hlink:hover {
color:white;
background-color:black;
}

    </STYLE>

You can try this....

<style>
td.navon {
background-color: #999999;
cursor: hand}
td.navoff {
background-color: #FFFFFF}
</style>

<table>
  <tr>
    <td class="navoff" onmouseover="className='navon'" onmouseoff="className='navoff'">
      td 1
    </td>
  </tr>
  <tr>
    <td class="navoff" onmouseover="className='navon'" onmouseoff="className='navoff'">
      td 2
    </td>
  </tr>
</table>

Here you go

td{
    background:red;
    color:white;
    padding:10px;
    border:1px solid white;
}

td:hover{
    background:blue;
}

<table>
    <tr>
        <td>test</td>
        <td>test</td>
    </tr>
</table>

Check working example at http://jsfiddle/LU9b7/1/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745460332a4628679.html

相关推荐

  • javascript - coloring a td on mouse hover - Stack Overflow

    I want to add a background color on a td as a mouse hover in smarty.How can I use create a hover I made

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信