I created a very simple popup/modalbox. I wanted to show it after clicking .openModal
button and to close it by clicking on .closeModal
or anywhere on the screen. The problem is i cant define the variable that would show if modal is opened(true) or closed(false).
What is the problem?
<div class="modal"></div>
<div class="modalContent">
<span class="closeModal">x</span>
</div>
<script>
var openModal = false;
$(".openModal").click(function(){
$(".modal").show();
$(".modalContent").show();
openModal = true;
})
$(".closeModal").on('click', function(){
$(".modal").hide();
$(".modalContent").hide();
openModal = false;
})
$("body").on('click', function(){
if(openModal){
$(".modal").hide();
$(".modalContent").hide();
}
})
</script>
var ...
? – Praveen Kumar Purushothaman Mar 3 '16 at 10:17