尝试在文本位于页面加载的输入中的情况下尝试使用自定义函数,以便将文本与文本在输入中创建“信息”类似文本的其余部分分组。我试过,,.bind('load')
,.ready()
,我没有得到任何东西。只是看看是否有可能解决这一路上的碰撞问题。自定义函数上的textarea的jQuery加载事件
//removed some of the validation code for simplicity.
/*
to set a grey text infomation into a input field
*/
$.fn.greyInfo = function (text)
{
//troubled code - start
$(this).load(function()
{
$(this).val(text);
$(this).css('color', 'grey');
});
//troubled code - end
$(this).blur(function()
{
if($(this).val() == "")
{
$(this).val(text);
$(this).css('color', 'grey');
}
});
$(this).focus(function()
{
if($(this).val() == text)
{
$(this).val("");
$(this).css('color', 'black');
}
});
}
发现我的回答 '$(本).blur();' 把这个在自定义函数 – thebtm
结束时,我不认为加载事件在这方面作为触发$(本)我认为它已经在你的调用之前触发,尝试在你使用某个对象的函数后触发它。 –