I am trying to add Diez tag #
after the pressed space using jquery when user type. I have created this DEMO from codepen.io.
In this d
There is a simple Javascript function to do the functionality;
function addDiszTag(str){
// var str = "Hi bro how are you?"
str = str.split(' ');
//Output will be turned to be ["Hi", "bro", "how", "are", "you?"]
var transformedArr = [];
str.forEach(function(ele){transformedArr.push("#"+ele) })
// ["#Hi", "#bro", "#how", "#are", "#you?"]
return transformedArr.join(' ');
//It will return "#Hi #bro #how #are #you?"
}
Please add validation for checking duplicate :-) Hope it helped