Empty Textboxes, class="loc" display "(City, State \ Country)" using italics and silver. Of course, Textboxes that do have data are displayed according to page defaults.
I noticed chaining and caching could be used. There are inheritances issues, so I am not bothering with using .addClass instead of targeting with .css.
$(function () {
var loc = $('.loc');
function desc() {
var tar = $(this);
if (tar.val().length == 0) {
tar.val("(City, State \\ Country)").css({
"color": "silver",
"fontStyle": "italic"
});
};
}
function data() {
var tar = $(this);
if (tar.val() == "(City, State \\ Country)") {
tar.val("").css({
"color": "black",
"fontStyle": "normal"
});
};
}
loc.each(desc).blur(desc).click(data);
});
How far off base am I on understanding proper formatting in jQuery?