Not sure what i am doing wrong but alert(titleTxt)
; shows always other_location
. I need add two onmouse
listeners but seems it is always attached to the last element.
function ghostText(name){
obj = $("input[name='"+name+"']");
titleTxt = obj.val();
obj.css('color', '#cccccc');
obj.mouseover(function() {
if(obj.val() == titleTxt){
obj.val("");
obj.css('color', '#333333');
}
alert(titleTxt);
});
obj.mouseout(function() {
if(obj.val() == ''){
obj.val(titleTxt);
obj.css('color', '#cccccc');
}
});
}
ghostText('keyword');
ghostText('other_location');