How to check whether a select box is empty using JQuery/Javascript

前端 未结 3 1590
感动是毒
感动是毒 2020-12-24 11:59

I have a select box that is being populated dynamically from a database. As of right now the population of this check box is working flawlessly.

I have added functio

3条回答
  •  庸人自扰
    2020-12-24 12:10

    To check whether select box has any values:

    if( $('#fruit_name').has('option').length > 0 ) {
    

    To check whether selected value is empty:

    if( !$('#fruit_name').val() ) { 
    

提交回复
热议问题