Dynamically Add Elements with JQuery
by aitnasser
HTML
<button id="myBtn">Add Element</button>
<section id="wrapper"></section>
CSS
.dialog_red_top_page{
display: block;
width: 100%;
position: relative;
z-index: 999;
height: 60px;
}
.inner_dialog_red_top_page{
padding: 10px 20px;
position: relative;
text-align: center;
background-color: #d64848;
}
.dialog_red_top_page_text{
display: block;
font-size: 14px;
line-height: 20px;
color: #fff;
font-weight: 700;
text-align: center;
vertical-align: top;
margin: 0;
}
JavaScript
$('#myBtn').click(function(){
$("<div class ='dialog_red_top_page'><div class ='inner_dialog_red_top_page'><p class='dialog_red_top_page_text'>test</p> </div></div>").appendTo('#wrapper');
});