Say I have a load button on my website that always if the user pushes the button loads new items. The field which should be loaded looks like that:
.main-box {
background-color: #ffffff;
height: 130px;
display: flex;
width: 798px;
border-right: solid;
border-left: solid;
border-bottom: solid;
border-color: #E6E6E6;
}
.text-in-main-box{
font-weight: bold;
font-family: rob;
width: 60%;
padding: 7%;
display: flex;
vertical-align: middle;
}
.container-for-button-in-main-box{
width: 40%;
display: flex;
vertical-align: middle;
flex-direction: column;
align-items: center;
justify-content: center;
}
.button-in-main-box{
display:inline-block;
padding:0.8em 1.2em;
margin:0 0.3em 0.3em 0;
box-sizing: border-box;
text-decoration:none;
font-family:rob;
font-weight:bold;
color:#ffffff;
background-color:#34E034;
text-align:center;
transition: all 0.2s;
font-size: 14px;
border-radius: 4em;
}
<div class="main-box">
<div class="text-in-main-box">Sage “Hallo, Welt" mit Python</div>
<div class="container-for-button-in-main-box"><span class = button-in-main-box>Löse Aufgabe</span></div>
</div>
How can I add more then one div which should load by klick on the button. I get it for one simple div which should load. But how can I add my whole code block (the div which I send) into an load button?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Load more</title>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
</head>
<body>
<h1>Load more</h1>
<div id="content"></div>
<button id="lmbutton" onclick="loadmore()">Load More</button>
<script>
var items = ["one", "twp", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]
var currentindex = 0
function loadmore(){
var maxresult = 2
for(var i = 0; i < maxresult; i++){
if(currentindex >= items.length){
$("#lmbutton").hide()
return
}
$("#content").append("<div>"+items[i+currentindex]+"</div>")
}
currentindex += maxresult
}
loadmore()
</script>
</body>
</html>