
November 20th, 2012, 11:19 AM
|
|
Contributing User
|
|
Join Date: Feb 2004
Posts: 202
Time spent in forums: 23 h 26 m 46 sec
Reputation Power: 10
|
|
JQuery: Need Help w/ Show or Hide on Form Field Click
I've got a jQuery script I use for hiding/showing default values in small forms:
Code:
$("#contactForm .textField").focus(function() {
if (!default_values[this.id]) {
default_values[this.id] = this.value;
}
if (this.value == default_values[this.id]) {
this.value = '';
}
$(this).blur(function() {
if (this.value == '') {
this.value = default_values[this.id];
}
});
});
The issue is that I need to use this script on multiple fields (with the same CSS class) within the same form. What syntax changes need to be made? Right now -- this script will work for the first field you click in -- but won't work for the other fields in the same form.
Thank you for your help.
|