javascript - Close Modal using CSS only -


i need close modal using css this: http://jsfiddle.net/raving/1mhsynmw/

however, can't work. modal below.

function alert(msg) {  	document.getelementbyid("alert").innerhtml = '<div class="modal-overlay"><div class="modal"><div class="modal-container"><h3>' + msg + '</h3><p>' + msg + '</p></div><p class="modal-footer"><a href="javascript:" id="ok">ok</a></p></div>';  }    alert("this text show modal. text show modal. text show modal. text show modal.");
body {    font-family:arial;    font-size:11px;  }  .modal {       position: fixed;       top: 20px;       margin-left: auto;       margin-right: auto;       left: 0;       right: 0;       width: 200px;       box-shadow: 0 4px 6px 1px rgba(50, 50, 50, 0.14);       background: #fff;  }  .modal p {  	 cursor:default;  }  .modal-container {  	 padding: 10px;  }  .modal p {  	 color:#555;  }  .modal-footer {  	 display:block;  	 border:1px solid #eee;  	 width:9.5%;  	 padding:3px;  	 background:#fff;  	 text-decoration:none;  	 float:right;  }  .modal-footer {       background: #fafafa;       border-top: 1px solid #eee;       margin-bottom: 0px;  	 margin-top:0px;  	 padding:8px;  	 height:25px;  }  .modal h3 {  	 margin:0px;  	 white-space: nowrap;       overflow: hidden;       text-overflow: ellipsis;       max-width: 175px;  }  .modal-last {  	 padding-bottom:0px;  }  .modal-overlay:before {       content: '';       position: fixed;       top: 0px;       left: 0px;       width: 100%;       height: 100%;       background: rgba(0, 0, 0, 0.5);  }
<div id="alert"></div>    <h3>content..</h3>  <p>just show it's modal</p>

question: there way close modal without using javascript? , not possible, how can use javascript close modal?

if don't want use jquery close modal when click on ok button similar following code plain javascript. have assign index selector work.

    //begin click event     document.getelementbyid("ok").addeventlistener("click",function(event){       /* hide element class name of modal.        note:if there more 1 element class name        modal code select first 1 in        collection of elements      */      document.getelementsbyclassname("modal")[0].style.display = "none";          });//end click event 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -