kembali ke pelajaran
Materi ini hanya tersedia dalam bahasa berikut: ????????, English, Espa??ol, Fran??ais, Italiano, ?????????, ??????????????, T??rk??e, ????????????????????, ????????????. Tolong, menerjemahkan ke dalam Indonesia.

Show a note near the element

pentingnya: 5

Create a function positionAt(anchor, position, elem) that positions elem, depending on position near anchor element.

The position must be a string with any one of 3 values:

  • "top" ??? position elem right above anchor
  • "right" ??? position elem immediately at the right of anchor
  • "bottom" ??? position elem right below anchor

It???s used inside function showNote(anchor, position, html), provided in the task source code, that creates a ???note??? element with given html and shows it at the given position near the anchor.

Here???s the demo of notes:

Buka sandbox untuk tugas tersebut.

In this task we only need to accurately calculate the coordinates. See the code for details.

Please note: the elements must be in the document to read offsetHeight and other properties. A hidden (display:none) or out of the document element has no size.

Buka solusi di kotak pasir.