jQuery selector for select elements with empty value attributes?

后端 未结 3 1279
挽巷
挽巷 2021-01-13 13:17

I\'m using the below selector to get all the form inputs that are pre-populated with a value.

$(\'input[value!=\"\"]\');

This works great a

3条回答
  •  一个人的身影
    2021-01-13 14:01

    value is not an attribute of select tag.

    So you need to try:

    var emptySelect = $('select').filter(function() {
                         return $.trim( $(this).val() ) == '';
                      });
    

提交回复
热议问题