A small question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

A small question

Is it possible to actually use the Cancel and Ok in the confirm() command OR Do you have to type about 50 lines of code for a working confirm() command? (This is in web)

19th May 2024, 1:18 AM
Kongpheng Lo
Kongpheng Lo - avatar
2 Answers
+ 5
Kongpheng Lo yes by example of w3schools https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_confirm2 <!DOCTYPE html> <html> <body> <h1>The Window Object</h1> <h2>The confirm() Method</h2> <p>Click the button to display a confirm box.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { let text; if (confirm("Press a button!") == true) { text = "You pressed OK!"; } else { text = "You canceled!"; } document.getElementById("demo").innerHTML = text; } </script> </body> </html> https://sololearn.com/compiler-playground/WJms7JFlgCy6/?ref=app
19th May 2024, 4:25 AM
BroFar - avatar
+ 1
19th May 2024, 12:29 PM
Kongpheng Lo
Kongpheng Lo - avatar