HTML + Add input field inside a dropdown box

前端 未结 4 1887
春和景丽
春和景丽 2020-12-03 23:23

A new idea came across my mind.Someone may have implemented this. I am trying to get a way to add a textbox inside a dropdown list.

Means I want to add a input box i

4条回答
  •  佛祖请我去吃肉
    2020-12-03 23:40

    The only possible way out is to use an autocomplete which has ul and li's or you can have an external input box and an add to list button which would add the text to the list

    
    
     
    
    
    

    In Jquery,

    $('input#insertOption').click(function(){
        var currentHtml = $.trim($('input#addOption').val());
        var currentVal = $.trim($('input#addOptionValue').val());
        if (currentVal  === '' || currentHtml  === ''))) {
            alert('Please enter value');
            return false;
        }
        $('select#country').append('');
    });
    

提交回复
热议问题