开发者

description text in a text field?

开发者 https://www.devze.com 2022-12-18 03:22 出处:网络
i want to put some description 开发者_Python百科text in light grey in a text field. then when a user clicks on it the text disappears and he can type whatever he wants.

i want to put some description 开发者_Python百科text in light grey in a text field. then when a user clicks on it the text disappears and he can type whatever he wants.

is there a jquery plugin for this? i dont know what to search for in google.


http://digitalbush.com/projects/watermark-input-plugin/


Yes -- what you want is relatively simple to do. Check out the following link:

JQuery Watermark


http://tlporfolio.site11.com/jdesc.html

This is the simplest thing I ever used. Append to a div with just one line of code, even set how much times it will display based on cookies. So technically even when you close the browser and open again it count as one time open.


$(document).ready(function() {
    $('#IDofTextField').css({'color': '#aaaaaa', 'font-style': 'italic'});
    $('#IDofTextField').attr('value', 'Your text in here');
    $('#IDofTextField').focus(function() {
        $('#IDofTextField').css({'color': '#000', 'font-style': 'normal'});
        $('#IDofTextField').attr('value', '');
    });
    $('#IDofTextField').blur(function() {
        if ($('#IDofTextField').val() == '') {
            $('#IDofTextField').css({'color': '#aaaaaa', 'font-style': 'italic'});
            $('#IDofTextField').attr('value', 'Your text in here');
        }
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号