I have some text which I display in the web page using GWT HTML object. This text contains a set of specific words. I want to popup something when user clicks ( also if he keeps mouse over it for sometime, if it is easy to implement that) on any of these special words.
How this could be achieved?
Please note that I have complete control over the text and I can add any specific tags around those special words if required.
From any event, you can easily get the exact element target using
event.getNativeEvent().getEventTarget(), which you could then check for some specific characteristics of marker elements you’d have inserted into the HTML. So, you’d attach mouse events to theHTMLwidget and use what’s called “event delegation”.(as a side note, about the use of a
data-*attribute: http://www.w3.org/TR/html5/elements.html#embedding-custom-non-visible-data-with-the-data-attributes )