How can I create an editable dropdownlist in HTML?

前端 未结 11 1122
终归单人心
终归单人心 2020-11-29 01:51

I\'d like to create a text field with a dropdown list that lets the user choose some predefined values. The user should also be able to type a new value or select a predefin

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 02:29

    This can be achieved with the help of plain HTML, CSS and JQuery. I have created a sample page:

    $(document).ready(function(){
       
        $(".editableBox").change(function(){         
            $(".timeTextBox").val($(".editableBox option:selected").html());
        });
    });
    .editableBox {
        width: 75px;
        height: 30px;
    }
    
    .timeTextBox {
        width: 54px;
        margin-left: -78px;
        height: 25px;
        border: none;
    }
    
    

提交回复
热议问题