js- textarea placeholder 换行显示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var placeholder = "This is a line \nthis should be a new line"
$(document).ready(function(){
if($('#recruit_info_jd').val() == ''){
$('#recruit_info_jd').val(placeholder)
$('#recruit_info_jd').css('color', "#999")
}
}
$('#recruit_info_jd').focus(function(){
if($(this).val() === placeholder){
$(this).val('');
$(this).css('color', '#404040');
}
});
$('#recruit_info_jd').blur(function(){
if($(this).val() ===''){
$(this).val(placeholder);
$('#recruit_info_jd').css('color', "#999")
}
});