스크립트 # 1 :라인 문자열 나누기
<textarea></textarea>
$('textarea').each(function() {
var $placeholder = "First line\nSecond one";
console.log('[function] shikamo__edit_placholder, data-placeholder: ' + $placeholder);
$(this).attr('value', $placeholder);
$(this).focus(function(){
if($(this).val() == $placeholder){
// reset the value only if it equals the initial one
$(this).attr('value', '');
}
});
$(this).blur(function(){
if($(this).val() == ''){
$(this).attr('value', $placeholder);
}
});
// remove the focus, if it is on by default
$(this).blur();
});
반환
<textarea>First line
Second one</textarea>
스크립트 # 2 :
<textarea data-placeholder="First line\nSecond one"></textarea>
$('textarea').each(function() {
var $placeholder = $(this).attr('data-placeholder');
console.log('[function] shikamo__edit_placholder, data-placeholder: ' + $placeholder);
$(this).attr('value', $placeholder);
$(this).focus(function(){
if($(this).val() == $placeholder){
// reset the value only if it equals the initial one
$(this).attr('value', '');
}
});
$(this).blur(function(){
if($(this).val() == ''){
$(this).attr('value', $placeholder);
}
});
// remove the focus, if it is on by default
$(this).blur();
});
반환
,210내가 스크립트 # 2에서 줄 바꿈
<textarea data-placeholder="First line\nSecond one">First line
Second one</textarea>
과 같은 결과를 얻을 수있는 방법
?
잘 작동합니다. 고마워. –