When Text Enter in Textarea then show text in DIV.but Condition is that,i append mutiple DIV then type text in Textare.then show text only one DIV not Other DIV.
My Code :
<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);
});
Your code is working your probably need to put it document.ready so that when the script for binding event is execute the element you are looking for is added to DOM
and include jQuery
$('.speechttxt').keyup(function () {
var txt = $(this).val();
$('.txtspeech').html(txt);
});
You can add jQuery using script tag.
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
<script type="text/javascript">
document.ready(function(){
$('.speechttxt').keyup(function () {
var txt = $(this).val();
$('.txtspeech').html(txt);
});
});
</script>
将类“ txtspeech”添加到要显示文本的div中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.