I have this div in my reactJS project:
<div
className="td-creator"
id="Creator"
tooltiptext="Melder"
onMouseOver={setToolTip}
onMouseOut={hideToolTip}
>
I am trying to get the value of tooltiptext by using getelementbyid.
I can succesfully store the div element in a variable name target and when I print it in the console it shows me this:
but when I try to use target.tooltiptext it returns undefined.
is there any way to acces the tooltiptext value in Javascript?
>Solution :
This is because tooltiptext is not a property of the HTMLDivElement.
Try getAttribute:
const toolTipText = target.getAttribute("tooltiptext");