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

后端 未结 4 1849
半阙折子戏
半阙折子戏 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:46

    I believe you can check to see if the option length is >0 saying that it has values and if not then it doesn't exist meaning it doesn't have values like so:

    if($("#addedchargeamtid option").length > 0 ) //if addedchargeamtid is the id of select tag
    {
       $('#removeButton').show();
    }
    else
    {
      $('#removeButton').hide();
    }
    

提交回复
热议问题