Placeholder怎么换行
Placeholder如何换行
使用js动态添加标签充,处理换行问题
1 var placeholder = 'This is a line \nthis should be a new line'; 2 $('textarea').attr('value', placeholder); 3 4 $('textarea').focus(function(){ 5 if($(this).val() === placeholder){ 6 $(this).attr('value', ''); 7 } 8 }); 9 10 $('textarea').blur(function(){ 11 if($(this).val() ===''){ 12 $(this).attr('value', placeholder); 13 } 14 });