smartFocus

授权协议 未知
开发语言
所属分类 jQuery 插件、 其他jQuery插件
软件类型 开源软件
地区 不详
投 递 者 闻人凯泽
操作系统 未知
开源组织
适用人群 未知
 软件概览

A small plugin to inject a text into inputs ortextareas as a label.
The text is removed when the element is focused and re-injected onblur if the element is leaved blank.

Here is the code to include in an external js or to paste on the page:

jQuery.fn.smartFocus = function(text) {
$(this).val(text).focus(function(){
if($(this).val() == text){
$(this).val('');
}
}).blur(function(){
if( $(this).val() == '' ){
$(this).val(text);
}
});
};

USAGE EXAMPLE:

var mail = '* E-mail';
$('#mail').smartFocus(mail);

This will inject the text "* E-mail" into the element (an input or a textarea) with id='mail'

Grab