javascript - Convert multiple Textareas to LI in unordered list -


I have an unknown number of textareas to process the data entered by the user to give me the list of elements of my content Need to change in

By using JavaScript and / or jQuery, I can change how:

  & lt; Textarea & gt; Content 1 & lt; / Textarea & gt; & Lt; Textarea & gt; Content 2 & lt; / Textarea & gt; & Lt; Textarea & gt; Content 3 & lt; / Textarea & gt;   

To do this:

  & lt; Ul & gt; & Lt; Li & gt; Content 1 & lt; / Li & gt; & Lt; Li & gt; Content 2 & lt; / Li & gt; & Lt; Li & gt; Content 3 & lt; / Li & gt; & Lt; / Ul & gt;   

I have to send a resultant UL to a variable sent to the AAJX service.

Editing - So far I have tried:

  var viewtactress = $ ('text: view:'); Var listItems = visibleTextareas.replace with (function () {return $ ('
  • gt;' $ (this) .val () + '& lt; / li & gt;');}); Var text = '& lt; Ul & gt; + List item + '& lt; / Ul & gt; '; Console.log (text);

    Due to being logged in to the console and lt; Ul & gt; [Object object] & lt; / Ul & gt; and the backend answers that it needs UL.

    Try something like this:

      var output = ' & Lt; Ul & gt; '; $ ('Texture'). Each (function () {output + = '
  • gt;' + $ (this) .val () + '& lt; / li & gt;';}); Output + = '& lt; / Ul & gt; ';

    Is this work for you?

    Edit: .val () is more appropriate in this case.

  • Comments

    Popular posts from this blog

    excel vba - How to delete Solver(SOLVER.XLAM) code -

    github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

    ios - Replace text in UITextView run slowly -