HTML:
<!-- try to change the value="" -->
<input class="test" type="text" value="">
jQuery
$(function () {
if (!$(".test").val()) {
alert("Empty");
$(this).addClass("removeMe");
} else {
alert("not Empty");
$(this).addClass("addMe");
}
});
Why $(this)
doesn't work here? And what is it possible to do about it if, say there's more than one element(.test
) to include, for example 3: if (!$(".test, .test2, .test3").val()) {