jQuery check if <input> exists and has a value
javascript, jquery
Solution
The input won't have a value if it doesn't exist. Try this...
if($('.input1').val())
Problem
I have the following example: ``` <input type="text" class="input1" value="bla"/> ``` Is there a way to check if this element exists and has a value in one statement? Or, at least, anything shorter then ``` if($('.input1').length > 0 && $('input1').val() != '') ``` Just getting frustrated here with mile-long conditions.