You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: files/en-us/web/api/htmlelement/beforetoggle_event/index.md
+8-25Lines changed: 8 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,8 +38,8 @@ A {{domxref("ToggleEvent")}}. Inherits from {{domxref("Event")}}.
38
38
39
39
## Examples
40
40
41
-
The examples below demonstrates how the `beforetoggle` event might be used for a {{domxref("Popover_API", "popover", "", "nocode")}} or {{htmlelement("dialog")}} element.
42
-
The same examples would work similarly on the other element types.
41
+
The examples below demonstrate how the `beforetoggle` event might be used for a {{domxref("Popover_API", "popover", "", "nocode")}} element.
42
+
The same examples would work similarly on a {{htmlelement("dialog")}} element.
43
43
44
44
### Basic example
45
45
@@ -77,7 +77,7 @@ function log(text) {
77
77
78
78
#### JavaScript
79
79
80
-
The code gets adds an event listener for the `beforetoggle` event and logs the state.
80
+
The code adds an event listener for the `beforetoggle` event and logs the state.
The `beforetoggle` event is cancelable if fired when opening an element.
101
101
102
-
Below we show how a popover that might first check if it is allowed to open, and if not, call {{domxref("Event.preventDefault()")}} to cancel the event.
103
-
In this example we use a button to set whether the popover can open or not: in a more "full featured" example this might depend on the application state, or the data in the popover being ready to display.
102
+
Below we show how a popover might first check if it is allowed to open, and if not, call {{domxref("Event.preventDefault()")}} to cancel the event.
103
+
In this example we use a checkbox to set whether the popover can open or not: in a more "full featured" example this might depend on the application state, or the data in the popover being ready to display.
104
104
105
105
#### HTML
106
106
107
-
The HTML consists of a popover, a button for toggling it open and closed, and a button for setting whether the button can be opened.
107
+
The HTML consists of a popover, a button for toggling it open and closed, and a checkbox for setting whether the popover can be opened.
108
108
109
109
```html
110
110
<buttonpopovertarget="mypopover">Toggle the popover</button>
@@ -137,7 +137,7 @@ function log(text) {
137
137
138
138
#### JavaScript
139
139
140
-
First we set up the code to simulate a state where we don't want to allow the popover to open.
140
+
First we set up the code to simulate a state where we want to allow the popover to open.
141
141
This is represented by the variable `allowOpen`, which is toggled when the associated checkbox is toggled.
0 commit comments