//获得焦点,若值为默认值,则赋空且修改样式:
function onInputFocus(obj)
{
if( obj.value==obj.title )
{
obj.value = "";
obj.className = "inputSomething";
}
}
//失去焦点,若内容为空,则赋回默认值和原样式:
function onInputBlur(obj)
{
if( obj.value=="")
{
obj.value = obj.title;
obj.className = "inputNothing";
}
}
<input type="text" title="欢迎留言,最多输入300个汉字" onfocus="onInputFocus(this);" onblur="onInputBlur(this);" />