Stefano Maglione
Stefano Maglione

Reputation: 4160

Background image on selected li by css

my issue is: Can I apply a background-image to a selectioned <li> that contain a link, only by css? Now by this:

.art-block  li:hover , .art-block  li:visited
{
    background-color:red !important;
}

I can only apply a background when mouse is over the link but if I move the mouse background desappear.

Upvotes: 1

Views: 103

Answers (1)

Mohsen Safari
Mohsen Safari

Reputation: 6805

I don't know a only CSS way but here is the JQuery way:

DEMO

$("li").click(function(){
    $(".selected").removeClass("selected");
    $(this).addClass("selected");
});

Upvotes: 1

Related Questions