0

I am building a website for language learners. When user sees a word they don't know they click on it and a JavaScript function will run.

So far I have a hand made function that finds the text being clicked. It works but seems not ideal.

Is there a way to make all text inside a <p> for example "clickable"?

Or is there a JavaScript library function to tell which word has been clicked?

  • Can you add the code snippet of the _hand made function_ you made? Would help us to know where you're at now and where we might be able too go from there. – aug Dec 03 '17 at 23:09
  • Hello and welcome to StackOverflow. Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read the [Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve) – Luca Kiebel Dec 03 '17 at 23:12
  • This may seem like an inefficient way of doing it, however, have you thought about making a Javascript function to loop through the text adding a `span` element to each word with an `onClick` attribute to call a function that shows the translation? – Thomas Smyth Dec 03 '17 at 23:14

0 Answers0