[Solved] Jquery How to put text into separate span after pasting it


Next time when asking a question please post a helpful descriptive title, and try to be a more descriptive. Just pasting your code in and saying here do this for me will get you a negative response. Thoroughly explain what you have tried and what you are trying to do. Next time you ask a question.

To help you out though with you current dilemma you can try something like this.

$("#span").click(function() {
  alert("1. all words into separate span, 2. all words gone after that ");
  var textArea = $('#words');
  var arrayOfWords = textArea.val().split(" ");
  var wordsInSpans="";
  $.each(arrayOfWords, function(i, word){
    console.log(word) // you can do anything you want with the word in here
        wordsInSpans += '<span>' + word + '</span>';
  })

  $('body').append(wordsInSpans);
  textArea.val(''); // This will set the value to blank
});

good luck with what you are trying to build

0

solved Jquery How to put text into separate span after pasting it