Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74406

How to close message box (div) when click outside using html code only (can't use jquery as page only accept html code?

$
0
0

please don't close it with "use jquery to close DIV " example. As I can only use HTML code on my page.

can anyone help me to find the code which close DIV (message box) when clicked outside. >> And these current 4 buttons are not aligned in the same line > is there any code to align the buttons in one line as well Thanks

.alert {
	display: none;
	padding: 20px;
	background-color: #f44336;
	color: white;
}

.closebtn {
	margin-left: 15px;
	color: white;
	font-weight: bold;
	float: right;
	font-size: 22px;
	line-height: 20px;
	cursor: pointer;
	transition: 0.3s;
}
<button onclick="document.getElementById('alert1').style.display='block'">Button1</button> <div id="alert1" class="alert"> <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>Message 1 </div><button onclick="document.getElementById('alert2').style.display='block'">Button2</button> <div id="alert2" class="alert"> <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>Message 2 </div><button onclick="document.getElementById('alert3').style.display='block'">Button3</button> <div id="alert3" class="alert"> <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>Message 3 </div><button onclick="document.getElementById('alert4').style.display='block'">Button4</button> <div id="alert4" class="alert"> <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>Message 4 </div>

Viewing all articles
Browse latest Browse all 74406

Latest Images

Trending Articles



Latest Images