I am trying to determine if a textarea is empty if a user deletes what is already pre-populated in the textarea using jQuery.
Anyway to do this?
This is what
Andy E's answer helped me get the correct way to working for me:
$.each(["input[type=text][value=]", "textarea"], function (index, element) {
if (!$(element).val() || !$(element).text()) {
$(element).css("background-color", "rgba(255,227,3, 0.2)");
}
});
This !$(element).val() did not catch an empty textarea for me. but that whole bang (!) thing did work when combined with text.