DE
js
class Tooltip {
constructor () {
this.style = document.createElement('style')
this.tooltips = document.querySelectorAll('.tooltip')
document.head.appendChild(style)
for (var i = 0, n = this.tooltips.length; i < n; i++) {
var attr = this.tooltips[i].getAttribute('data-tooltip')
if (attr) {
this.tooltips[i].addEventListener('click', this.clickEvent)
}
}
}
clickEvent (event) {
var x = event.x - event.target.offsetLeft
var y = event.y - event.target.offsetTop
this.style.innerHTML = '.tooltip-active[data-tooltip]::after { left: ' + x + 'px; top: ' + y + 'px;opacity:1; }'
event.target.classList.toggle('tooltip-active')
}
}



