Making HTML5 datalist visible when focus event fires on input

前端 未结 4 1139
花落未央
花落未央 2021-02-04 00:11

As some might know already styling select element is a nightmare, literally impossible without some javascript trickery. The new datalist in HTML5 could serve the same purpose s

4条回答
  •  温柔的废话
    2021-02-04 00:41

    I use the following code:

    
    
    
        
        
        
    
    

    mouseover:
    Set focus and memorize old value in a -- g l o b a l -- variable

    mousedown:
    Delete value and show datalist (built in functionality)

    mouseup:
    Restore old value

    Then select new value.

    Find this an acceptable workaround towards a combobox.

提交回复
热议问题