This is probably very simple but I can't seem to put it together. I am simply trying to find the class of the anchor tab that apears right before my input field. My code looks like this:
$(':input[required]').each(function () {
if ($(this).val() === '' && $(this).attr('type') == 'File') {
alert($(this).prev("a").attr('class')); //here is my problem it returns undefined.
}
}
})
So i am simply trying to grab the class of the anchor tag right above my input field. $(this) being an input field. Thank you for any help.
My html looking like this:
<a class="ClassXYZ">File</a>
<input required type='File'>
Im trying to return ClassXYZ.