jQuery check if <input> exists and has a value

后端 未结 7 797
情歌与酒
情歌与酒 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 00:44

    if($('#user_inp').length > 0 && $('#user_inp').val() != '')
    {
    
        $('#user_inp').css({"font-size":"18px"});
        $('#user_line').css({"background-color":"#4cae4c","transition":"0.5s","height":"2px"});
        $('#username').css({"color":"#4cae4c","transition":"0.5s","font-size":"18px"});
    
    }
    

提交回复
热议问题