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');
}
});
});
精彩评论