retour au cours
Ce contenu n'est disponible que dans les langues suivantes :English, Español, فارسی, Italiano, 日本語, Русский, Türkçe, Українська, Oʻzbek, 简体中文. Merci de

Write JavaScript that shows a tooltip over an element with the attribute data-tooltip. The value of this attribute should become the tooltip text.

That’s like the task Comportement info-bulle, but here the annotated elements can be nested. The most deeply nested tooltip is shown.

Only one tooltip may show up at the same time.

For instance:

<div data-tooltip="Here – is the house interior" id="house">
  <div data-tooltip="Here – is the roof" id="roof"></div>
  ...
  <a href="/?originalUrl=https%3A%2F%2Ffr.javascript.info%2F%26quot%3Bhttps%3A%2F%2Fen.wikipedia.org%2Fwiki%2FThe_Three_Little_Pigs%26quot%3B%2520data-tooltip%3D%26quot%3BRead%2520on%25E2%2580%25A6%26quot%3B%26gt%3BHover%2520over%2520me%26lt%3B%2Fa%26gt%3B%26lt%3B%2Fdiv%26gt%3B%253C%2Fcode">

The result in iframe:

Open a sandbox for the task.