onHover字体颜色不变

时间:2014-04-28 13:54:45

标签: jquery html css

我有一个输入框,当用户开始输入时,它会显示一个div,其中包含可供选择的俱乐部列表。

我现在只想尝试添加一些样式,并且我的.clubLink:悬停类有问题。

CSS:

<style>
    .clubList { display: none; width: 250px; margin-top: -5px; margin-left: -4px; border: 1px solid; }
    .clubLink { width: 240px; padding: 5px; }
    a { text-decoration: none; color: black; font-size: 10px; }
    a:hover { color: #FFFFFF; }
    .clubLink:hover { background-color: #0066FF; color: #FFFFFF; }  
</style>

HTML / ColdFusion的:

<table width="450" cellpadding="0" cellspacing="0" class="content">
    <tr>
        <th colspan="2" class="content">Club Select</th>
    </tr>
    <tr class="content2">
        <td>
            <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="left" class="content"><strong>Please Select a Club:</strong></td>
                    <td align="left"><input type="text" name="clubFilter" id="clubFilter" class="formItem"></td>
                </tr>
                <tr>
                    <td align="left">&nbsp;</td>
                    <td align="left" class="content">   
                        <div id="clubList" class="clubList">
                            <cfloop query="Variables.getClubs">
                                <div class="clubLink">
                                    <span class="clubName"><a href="passwordreset.cfm?cid=#clubID#">#clubName#</a></span>
                                </div>
                            </cfloop>
                        </div>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

JQuery的:

<script>    

$('#clubFilter').bind("keyup", function() {
    var text = $(this).val().toLowerCase();
    var items = $(".clubName");

    items.parent().hide();

    items.filter(function () {
        return $(this).text().toLowerCase().indexOf(text) > -1;
    }).parent().show();

    $('#clubList').css("display", "block");
});

</script>

当我将鼠标悬停在已过滤列表中的俱乐部记录div(clubLink类)上时,背景颜色会发生变化但字体颜色仍为黑色。

字体更改为白色的唯一时间是我实际悬停俱乐部名称并应用锚点样式。

任何人都知道我哪里出错了?

非常感谢

3 个答案:

答案 0 :(得分:1)

使用

.clubLink:hover { background-color: #0066FF; color: #FFFFFF; }  
.clubLink:hover a{color: #FFFFFF; }  

答案 1 :(得分:0)

您的主播应具有display:block值,以便在您悬停在.clubLink元素时触发

答案 2 :(得分:0)

您正在更改div字体的颜色,但文本颜色由a给出,因此在悬停div时它保持不变是有意义的。你要做的是让a继承div的颜色。

http://jsfiddle.net/sY4Gf/

 .clubList {
     display: none;
     width: 250px;
     margin-top: -5px;
     margin-left: -4px;
     border: 1px solid;
 }
 .clubLink {
     width: 240px;
     padding: 5px;
     color:red; /* for testing */
 }
 a {
     text-decoration: none;
     font-size: 10px;
     color:inherit;
 }
 .clubLink:hover {
     background-color: #0066FF;
     color: #FFFFFF;
 }
相关问题