HTMLAreaElement: interestForElement property

The interestForElement property of the HTMLAreaElement interface returns a reference to the interest invoker target element, in cases where the associated <area> element has been specified as an interest invoker.

See Creating an interest invoker for more details.

Value

An Element object instance, or null if the associated <area> element has no interest invoker target.

Examples

Basic interestForElement usage

In this example, we use an <area> element's interestForElement property to retrieve its target element's tagName. The tagName is then printed into the <area> element's text content.

HTML

We set up a relationship between the <area> element interest invoker and its target — a <div> element — by setting the <area> element's interestfor attribute equal to the <div> element's id. We also turn the <div> element into a popover by setting a popover attribute on it.

html
<map>
  <area href="#" shape="default" interestfor="mypopover" />
</map>
<div id="mypopover" popover>I am a <code>&lt;div&gt;</code> element.</div>

JavaScript

We grab a reference to the <area> element in script, then set its text content equal to a string containing the target element's tagName, retrieved via invoker.interestForElement.tagName.

js
const invoker = document.querySelector("[interestfor]");
invoker.textContent = `My target is a ${invoker.interestForElement.tagName} element`;

Result

The example renders like this:

Try showing interest in the area (for example, by hovering or focusing it) to make the <div> appear.

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also