问题
I've been trying to change the background color of the focused item in jQuerys autocomplete box, but is was harder than I thought. My mission is to change the blue color to something else. Is that possible?
It's not the hover color. That one I already manage to change. No it's the color that displays when you use the keyboard to change focused item.
Here's my fiddle: https://jsfiddle.net/18b15bw1
I've used the exact code from the example that jQuery provides: http://jqueryui.com/autocomplete/#categories
I just added this to make the hover red:
.ui-menu-item .ui-menu-item-wrapper:hover {
background: red;
}
回答1:
Add the .ui-state-active
class as well:
.ui-menu-item .ui-menu-item-wrapper:hover, .ui-menu-item .ui-state-active {
background: red;
}
jsFiddle example
Actually, you don't even need your hover rule, this handles both mouse and keyboard:
.ui-menu-item .ui-state-active {
background: red;
}
jsFiddle example
来源:https://stackoverflow.com/questions/42305701/cant-change-style-to-jquerys-autocomplete-element