我在編碼方面仍然很新,而且我正在幫助一些有些東西的朋友。在HTML中彈出雙彈出
所以,我在代碼裏面做了一個彈出式文本,這個按鈕是一個按鈕,我想做一個第二到第四個,每個都有自己的文本和特定的東西,但是我沒有能夠,請任何幫助嗎?
這是我的代碼。
var modal = document.getElementById('myModal1');
var btn = document.getElementById("myBtn1");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
padding-top: 100px;
/* Location of the box */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
<body style="background-color:#FFE4C4;">
<div class="container-fluid">
<br><br>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10">
<!-- Trigger/Open The Modal -->
<button id="myBtn1" class="button"><H1>FRUTAS Y VERDURAS</H1></button>
<div id="myModal1" class="modal">
<div class="modal-content">
<span class="close">×</span>
<ol style="list-style-type: 1">
<li>Deben lavarse con agua y utilizar media cucharada de cloro.</li>
<li>Lavar las frutas y verduras y si es necesario dejarlas en agua con el cloro y escurrirlas después de 30 minutos.</li>
<li>Secarlas bien.</li>
</ol>
</div>
</div>
</div>
<div class="col-md-1"></div>
</div>
</div>
</body>
'「於是,我做了一個彈出文本我的代碼裏面,這有一個按鈕,我想打一個第二和高達4一個,每個都有它自己的文本和具體的東西「」嗯,什麼? –
爲什麼不使用相同的代碼來創建其他按鈕和模式?或者你是否複製了別人的代碼並且不理解它? –