1
저는 이모티콘으로 작업하고 있습니다. 텍스트 영역을 비워두면 값을 설정하기 만하면됩니다. 하지만 작동하지 않습니다. append()
값,하지를 설정하는 데 사용, 유사Textarea를 비울 수 없습니다.
$('#textarea').val('');
: 내 코드는 여기에 사용 val()
하지 text()
, html()
또는 empty()
, textarea
a의 값을 지 웁니다
$('.tooltiptext .emoticon').click(function() {
$in = $(this);
console.log($in);
setTimeout(function() {
var dataText = $("#text").val();
$('#text').append(dataText + $.emoticons.replace($in.html()));
var dataCode = $in.context.innerText;
console.log(dataCode);
var dataTextArea = $("textarea").val();
console.log(dataTextArea + dataCode);
//$('#textarea').html('');
$('#textarea').empty();// it not working
console.log($('#textarea').val());
$('#textarea').append(dataTextArea + dataCode + ' ');
}, 100);
});
$('textarea').on('keypress', function(e) {
if (e.which == 32 || e.which == 8) {
$in = $(this);
setTimeout(function() {
$("#text").html($.emoticons.replace($in.val()));
}, 100);
}
});
감사합니다. 하지만 왜 .append 작업을하지 않았다 ?? –
기본 요소의 'value' 속성을 설정하기 때문입니다. 'append()'는 DOM에 완전히 새로운 요소를 만드는 데 사용됩니다. –