Change Select List Option background colour on hover

前端 未结 8 746
小蘑菇
小蘑菇 2020-11-22 12:21

Is it possible to change the default background color of a select list option on hover?

HTML:


                        
    
提交评论

  • 2020-11-22 13:10

    The problem is that even JavaScript does not see the option element being hovered. This is just to put emphasis on how it's not going to be solved (any time soon at least) by using just CSS:

    window.onmouseover = function(e)
    {
     console.log(e.target.nodeName);
    }
    

    The only way to resolve this issue (besides waiting a millennia for browser vendors to fix bugs, let alone one that afflicts what you're trying to do) is to replace the drop-down menu with your own HTML/XML using JavaScript. This would likely involve the use of replacing the select element with a ul element and the use of a radio input element per li element.

    0 讨论(0)
  • 提交回复
    热议问题