1 <!DOCTYPE html>
2 <html>
3 <body>
4
5 <h1>The Element Object</h1>
6 <h2>The focus() and blur() Methods</h2>
7 <p>Test function by clicking button</p>
8
9 <input type="text" id="element" value="A text field">
10
11 <button type="button" onclick="callFunction(true)">Set focus</button>
12 <button type="button" onclick="callFunction(false)">Lose focus</button>
13
14 <script>
15 function callFunction(set) {
16 const element = document.getElementById("element");
17 set ? element.focus() : element.blur();
18 }
19 </script>
20 </body>
21 </html>