Textareaにテキストを入力すると、DIVにテキストが表示されますが、条件は、複数のDIVを追加してTextareにテキストを入力すると、他のDIVではなく1つのDIVのみをテキストに表示することです。
私のコード:
<button data-bind="adds">ADD</button>
<div data-bind="foreach: items">
<div class="SpeechBubble" id="speechID" data-bind="attr: { class: 'SpeechBubble' }">
<div class="pointer bottom " id="pointer"></div>
<div class="txtspeech"></div>
</div>
</div>
var SpeechBubble = function () {
this.items = ko.observableArray();
this.adds = function (item) {
this.items.push(item);
}
}
ko.applyBindings(new SpeechBubble());
$('.speechttxt').keyup(function () {
var txt = $(this).val();
$('.txtspeech').html(txt);
});