Can't change style to jQuery:s autocomplete element

孤街醉人 提交于 2019-12-12 03:33:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!