Hi team,
I would like to do clickable any word (inside an item, or div, or p tag, or span…)
and return the clicked word. I use ionic 5 Angular.
I would appreciate any idea or suggestion.
Thanks a lot.
In jQuery is similar to this:
$("p").click(function() {
var aWord = window.getSelection();
console.log(aWord);
});
Never done this before, i think i would create a Component that splits the Text at every blank and created the Text by many single <span>
Elements which all have a own Click Function
Do you have very specific human language requirements for your app (such as “it’s an app for teaching people French, so I can be certain that all the text is in French”?) I ask because in many languages (especially East Asian ones), the concept of what constitutes a “word” is itself an extraordinarily difficult problem, and so if you’re going to broadly localize this app, you should make sure that it’s truly a super-important feature, because it’s going to be hard to do in some languages.
That being said, you may be interested in a Medium-inspired text selection directive by the prolific Ben Nadel.