I have merged example code that uses "this" in two ways and I do not understand which is correct and when to use each:
$('input[type="text"].requiredText').each(function(){
if (this.value == '' || this.value == 'Required'){
this.value = "Required"
$(this).css({'color':'#C0C0C0'});
}
$(this).blur(function(){
blnTextHasFocus = false;
if (this.value == '') {
this.value = "Required";
$(this).css({'color':'#C0C0C0'});
}
});
$(this).click(function(){
blnTextHasFocus = true;
if (this.value == "Required") {
this.value = ""
$(this).css({'color':'black'});
}
});
});
Can someone please clarify the differences and when to use $(this) vs this? Strange, in the 4 books on jQuery I own, none discuss "this" and it seems to be very important.
TIA,
John