December 7, 2010
Change Unordered list item's color on focus?
Question by Damien Joe
How can we change an unordered list’s item color when it is focused with tab or clicked with mouse using CSS ?
Edit:
Check JSFiddle
Answer by benhowdle89
.form li input:focus
{
background-color:yellow;
}
Check that…
If your interested, this jQuery may work, please someone step in and correct it if its wrong!
$(".form li input").click(function(){
$(this).closest("li").css("background-color","yellow");
});
$(".form li input").blur(function(){
$(this).closest("li").css("background-color","white");
});
Answer by Starx
Here is your pure CSS solution http://jsfiddle.net/Starx/a93Rb/, only compatible with FF for now. You can make it compatible for the remaining browsers.