jQuery enable/disable show/hide button w/ SELECT options. Get remaining option values

后端 未结 4 1864
半阙折子戏
半阙折子戏 2021-01-23 05:05

I have a select list which is being populated using the values from a text field. I also have two buttons: an add button which adds the entered value to the select list and a re

4条回答
  •  故里飘歌
    2021-01-23 05:58

    For best answer, Try below code :

    Add Options to Select Tag Using Jquery

    $(document).ready(function(){
    
    //Function To Add or Remove New Option Field in Form
    var i=2;
    $(".add").on("click", function add_new(){
    $(".more").append($("

    ").append( "", $("",{class:'add', src:'images/add.png'}).click(function(){add_new();}), $("",{class:'del', src:'images/del.png'}).click(function(){$(this).parent().remove();}) )) i=i+1; }); //Below Function Executes on Click of create select Button $("#button").on("click",function(){ //To Clear Previous Select Option Field if Exists in Div $("#prm").empty(); //Creating Select Option in Div $("#prm").append(""); //Creating Options and Adding it To Above Select Tag $("input[type=text]").each(function(){ if($(this).val()==""){ alert($(this).attr('id')+" is Empty !"); } else{ $("select").append(''); } }); }); });

    http://www.formget.com/jquery-add-option-to-select/

提交回复
热议问题