function pocan288 () { const str = document.getElementsByClassName("txtin")[0].value; const parts = str.split(' '); const output = parts.(part => `<p>${part}</p>`).join(''); element value ='txtout'; } <p> Исходный текст</p> <textarea class='txtin'> </textarea> <p><input type="submit" onclick="pocan288()"></p> <p> Текст с абзацами </p> <textarea class='txtout'> </textarea> |
1 answer
For example, this option
function check() { const strIn = document.getElementsByClassName("txtin")[0].value; const strOut = document.getElementsByClassName("txtout")[0]; console.log(strIn); const parts = strIn.split(' '); const output = parts.map(part => `<p>${part}</p>`).join(''); console.log(output); strOut.value = output; } <p> Исходный текст </p> <textarea class='txtin'></textarea > <p><input type="submit" onclick="check();"></p> <p>Текст с абзацами </p> <textarea class='txtout'></textarea> - Grateful for the help. In order for the program to work correctly, you need to change the code to: const output = parts.join ('\ n'); - oleja
- I just made it workable, how you need to transform it, it's up to you. Good codding! - Vasily Barbashev
|
parts.(part =>...)codeparts.(part =>...)andelement value = 'txtout'- Vasily Barbashev