JSFiddle - React, Tailwind, and code Playground

by Joe Saad

HTML

<textarea id="tags"></textarea>

CSS

.tag {background-color:#ccc;
    padding:2px; }

JavaScript

$(function(){
    
    $('#tags').keyup(function(e){
    var message = $("#tags").val();    
        
       
        
        
         if (e.which ==32) {
             
          //alert('spacebar has been pressed');
        
          //  $split_point = ' - ';
          //  $string = 'this is my - string - and more';
          //  $result = array_map('strrev', explode($split_point, strrev($string)));
            var word = message.split(" ");
            // alert(word[1]);
            // alert(word.length);
             for (i=0; i<word.length-1; i++){
                 word[i].addClass('tag');
             }
             
        }                           
    });
});