+ 1

How to get output value in textarea not in div ?

Enter a list of comma separated words:<br> <input id=words type=text size=100 value='foo, bar, baz'></input> <br> Output divs: <div id=container></div> <script> (function() { var debounce, input = document.getElementById('words'), output = document.getElementById('container'), update = function() { var words = input.value.trim().split(/,\s*/); while (output.firstChild) output.removeChild(output.firstChild); for (var i = 0; i < words.length; i++) { var div = document.createElement('div'); div.textContent = words[i]; output.appendChild(div); } }; input.addEventListener('input', function() { window.clearTimeout(debounce); debounce = window.setTimeout(update, 150); }, false); update(); })(); </script>

22nd Jun 2023, 5:59 AM
Raja
Raja - avatar
8 odpowiedzi
23rd Jun 2023, 12:57 PM
Bob_Li
Bob_Li - avatar
+ 1
no it's not working
22nd Jun 2023, 9:09 AM
Raja
Raja - avatar
+ 1
no every word divide into different textarea Bob_Li
24th Jun 2023, 4:13 AM
Raja
Raja - avatar
+ 1
Raja Look at my code again. I put the code below an <hr>
27th Jun 2023, 5:41 PM
Bob_Li
Bob_Li - avatar
0
yeah because you are updating output value in div as I can see
22nd Jun 2023, 8:41 AM
Jayesh Mishra
Jayesh Mishra - avatar
0
Raja ok, maybe in your original code, instead of: document.createElement("div") you use: document.createElement("textarea")
24th Jun 2023, 4:20 AM
Bob_Li
Bob_Li - avatar
0
I already tried that, but it didn't work. Bob_Li
27th Jun 2023, 4:46 PM
Raja
Raja - avatar
0
Thank you.
30th Jun 2023, 4:39 PM
Raja
Raja - avatar