function checkInputData() {
$('.mainSearchSubmit').live('click', function () {
var inputData = $(this).parent().children().eq(0).val();
console.log(inputData.length);
//this returns undefined
console.log(inputData);
//and this returns text from inpu so i know there is data
});
}
Any ideas why is this happening, in other cases when retrieving val() from input it always comes as string??
The only explanation to
lengthbeing undefined is if inputData is not a string. You neglected to mention what type of input you’re working with, but in any case, casting to string should solve the issue: