jQuery check if <input> exists and has a value

后端 未结 7 779
情歌与酒
情歌与酒 2021-02-01 00:07

I have the following example:


Is there a way to check if this element exists and ha

相关标签:
7条回答
  • 2021-02-01 01:10

    You can do something like this:

    jQuery.fn.existsWithValue = function() { 
        return this.length && this.val().length; 
    }
    
    if ($(selector).existsWithValue()) {
            // Do something
    }
    
    0 讨论(0)
提交回复
热议问题