Placeholder如何换行

来源:互联网 发布:用友软件怎么建账 编辑:程序博客网 时间:2024/06/08 20:25

使用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     });
复制代码

 


原创粉丝点击