3
I’m trying to create a function that traverses any text by selecting letter as the effect of you hovering your mouse by selecting text slowly.
I used the select() but it selects all the text.
Example:
function SelectText(element) {
  var doc = document;
  var text = doc.getElementById(element);
  if (doc.body.createTextRange) {
    var range = doc.body.createTextRange();
    range.moveToElementText(text);
    range.select();
  } else if (window.getSelection) {
    var selection = window.getSelection();
    var range = doc.createRange();
    range.selectNodeContents(text);
    selection.removeAllRanges();
    selection.addRange(range);
  }
}
$('p').click(function() {
  SelectText("selectme");
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<p id="selectme">Silvio Santos Ipsum É fácil ou não éam? Mah é a porta da esperançaam. Ma vai pra lá. É por sua conta e riscoamm? Patríciaaammmm... Luiz Ricardouaaammmmmm. O arriscam tuduam, valendo um milhão de reaisuam. Ma! Ao adquirir o carnê do Baú, você estará concorrendo
  a um prêmio de cem mil reaisam. Eu não queria perguntar isso publicamente, ma vou perguntar. Carla, você tem o ensino fundamentauam? Ma quem quer dinheiroam? Estamos em ritmo de festamm. Eu só acreditoammmm.... Vendoammmm. Ma vejam só, vejam só. É com
  você Lombardiam.</p>I believe that the effect of selecting text cannot be triggered automatically ( just calling a function without triggering an event). I needed a click event to trigger it.
How can I make this effect?
You want to select only the letter the mouse is, or the whole text?
– Randrade
Puts each word inside a tag.
– Lucas Fontes Gaspareto