0

Each <a link is an anchor for jQuery to hide(show) certain divs.

I'm using this CSS to handle hover style:

ul.textMenu a:hover

{   
    border-bottom: 3px solid #ff5c00;
    margin-bottom: -3px;
}

After the user clicks an item, I want that border-bottom to persist. How do I do this?

menu

4

2 回答 2

5

添加一个 CSS 规则

ul.textMenu a.clicked

{   
    border-bottom: 3px solid #ff5c00;

}

然后是一些js

$('ul.textMenu a').click( function() {
    // Remove the class clicked so that we have only one clicked item
    // Since there might be more than one ul i finde the parent.
    $(this).closest('ul.textMenu').find('a').removeClass('clicked')
    $(this).addClass('clicked');
} );
于 2012-10-30T19:20:18.257 回答
1
jQuery('ul.textMenu a').click(function () {
    jQuery('ul.textMenu a').removeClass('active');
    jQuery(this).addClass('active');
});

为 ul.textMenu a.active 设置 css 以保持 CSS 边框

于 2012-10-30T19:20:35.477 回答