Find first empty input field

前端 未结 4 2051
温柔的废话
温柔的废话 2021-01-05 08:33

This simple selector finds the first empty text input field in my form but skips over password type inputs:

$(\'input:text[value=\"\"]:first\').focus();
         


        
4条回答
  •  自闭症患者
    2021-01-05 09:17

    By using comma you can insert multiple selector. It works like an OR operator.

    $('input:text[value=""]:first,input:password[value=""]:first')
    

提交回复
热议问题