Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

popovertargetaction — a button's action on a popover

The popovertargetaction attribute determines whether a button shows, hides, or toggles the popover identified by popovertarget. A missing attribute or invalid value means toggle.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

popovertargetaction="toggle"
popovertargetaction="show"
popovertargetaction="hide"

popovertargetaction is an enumerated attribute on a button controlling a popover. popovertarget identifies the target: its value must match the id of an element with a popover attribute in the same tree.

show shows the target, hide hides it, and toggle switches its visibility. An omitted attribute, an empty value, and an unknown value all mean toggle. Repeating show does not hide a visible target; hide does not show a hidden target.

The attribute alone neither creates a popover nor identifies its target. A disabled button does not trigger this operation. In the example, type="button" prevents form submission, while popover="manual" disables dismissal by clicking outside and by close requests such as Escape.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Popover actions</title>
<button type="button" popovertarget="info" popovertargetaction="show">Show</button>
<div id="info" popover="manual">
  Details
  <button type="button" popovertarget="info" popovertargetaction="hide">Hide</button>
</div>
</html>

Result

Initially: Show is visible; Details and Hide are hidden. Activate Show: Details and Hide become visible. Activate Show again: they remain visible. Activate Hide: Details and Hide become hidden.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources