javascript - Pop outs using js when clicked on a box -
javascript - Pop outs using js when clicked on a box -
i created simple website going part of bigger project: here screen shot: , here code:
<!doctype html> <html> <head> <script type="text/javascript"> function popup () { var thought = prompt("please come in thougt"); } </script> <style> .fixed-size-square { display: table; width: 200px; height: 200px; background: green; } .fixed-size-square span { display: table-cell; text-align: center; vertical-align: middle; color: white } .size-square { display: table; width: 200px; height: 200px; background: green; } .size-square span { display: table-cell; text-align: center; vertical-align: middle; color: white } .square { display: table; width: 200px; height: 200px; background: green; } .square span { display: table-cell; text-align: center; vertical-align: middle; color: white } .fixed-size-square, .size-square, .square { float: left; margin: 20px; zoom: 1; position: relative; box-shadow: 10px 10px 5px #888888; /*position: absolute;*/ /*margin: auto;*/ } button { position: relative; margin: 0px auto; } .divn { padding:30px; background:red; width:1px; border-radius:35px; top: 0px; bottom: 0px; left: 0px; right: 0px; /*position: absolute; margin: auto;*/ } </style> </head> <body> <h1>welcome zen module</h1> <div class='divn'></div> <div class="fixed-size-square" onclick="popup();"> <span>past thoughts</span> </div> <div class="size-square" onclick="popup();"> <span>present thoughts</span> </div> <div class="square" onclick="popup();"> <span>future thoughts</span> </div> <button>i've no thoughts</button> </body> </html>
i want have 2 functions window.prompt("question", "default")
. when click on okay
in prompt, function should read okay clicked
, , when cancel
button clicked, function should read cancel clicked
. how can it?
use below code
var x = prompt("dvdvbd", "default"); if (x != null) { //if user click ok //do } else { //if user click cancel //do }
javascript html css
Comments
Post a Comment