File: checkbox.html

package info (click to toggle)
python-playwright 1.55.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,728 kB
  • sloc: python: 53,655; javascript: 383; sh: 216; makefile: 6
file content (42 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (25)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
  <head>
    <title>Selection Test</title>
  </head>
  <body>
    <label for="agree">Remember Me</label>
    <input id="agree" type="checkbox">
    <script>
      window.result = {
        check: null,
        events: [],
      };

      let checkbox = document.querySelector('input');

      const events = [
        'change',
        'click',
        'dblclick',
        'input',
        'mousedown',
        'mouseenter',
        'mouseleave',
        'mousemove',
        'mouseout',
        'mouseover',
        'mouseup',
      ];

      for (let event of events) {
        checkbox.addEventListener(event, () => {
          if (['change', 'click', 'dblclick', 'input'].includes(event) === true) {
            result.check = checkbox.checked;
          }

          result.events.push(event);
        }, false);
      }
    </script>
  </body>
</html>