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