JSFiddle - React, Tailwind, and code Playground
JavaScript
var string = "This is where <span>I got stuck</span> and I am <span>clueless</span> can anyone <span>help please</span> ";
var pos = [];
string.split(' ').forEach(function(val,i){
if(val.indexOf('<span>') > -1){
pos.push({
postion:i,
})
}
});
var wordCount = $('<div/>').html(string).find('span').map(function(){
return this.innerText.split(' ').length
})
console.log(wordCount)