Show DIV Content on Hover, Focus and Click

Showing extra information when a user points to an element can be useful, but a mouse-only mouseover interaction excludes keyboard and touch users. Use an interaction that also works with focus and, where appropriate, click/tap.

Prefer native disclosure when suitable Top ↑

For content users intentionally open and close, <details> and <summary> often provide a better native solution than manually showing a floating DIV.

Hover and keyboard-focus example Top ↑

What is HTML?

const trigger = document.getElementById('helpLink');
const panel = document.getElementById('helpText');

['pointerenter', 'focus'].forEach(type =>
  trigger.addEventListener(type, () => panel.hidden = false)
);
['pointerleave', 'blur'].forEach(type =>
  trigger.addEventListener(type, () => panel.hidden = true)
);

Original Plus2net demo Top ↑

The existing demonstration is preserved for comparison with the older mouse-event technique.

Open DIV description demo

DIV basics DIV positioning DIV click interaction Show/hide layer





plus2net.com







Yaz

25-01-2012

GREAT JOB! BIG THANKS! FOR THIS IS EXTREMELY USEFULL!
dipesh

04-12-2013

It's a great site to learn.
I learn something new about <div> tag and it's become very useful to me.
Thank you



✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer