jQuery Add/Remove Input Fields
A script that uses event delegation and the .live() method for adding and deleting extra input form fields.
HTML
<div id="block">
<h2>Название товара 1</h2>
<div id="foto"></div>
<a href="#" class="button">Button</a>
</div>
<!--При клике на кнопку, открывается модальное окно-->
<div id="modalbox">
<h3>Название товара 1</h3>
<p>модальное окно<p>
<input type="text name="name" placeholder="Ваше имя">
<input type="text name="email" placeholder="E-mail">
<a href="#" class="send">Отправить</a>
</div>
CSS
#block {
width: 300px;
height: 205px;
background: #ccc;
margin: 20px;
text-align: center;
float: left;
}
#block h2 {
font:bold 25px Arial;
line-height: 40px;
background: #eee;
outline: 1px solid #ccc;
}
#foto {
width: 280px;
height: 110px;
background: #eee;
margin: 10px;
}
.button {
background: red;
margin: 0px 0 0 210px;
padding: 3px;
font: bold 20px Arial;
color: #fff;
text-decoration: none;
}
#modalbox {
float: left;
width: 300px;
height: 205px;
background: #ccc;
margin: 90px;
text-align: center;
}
#modalbox h3 {
font:bold 25px Arial;
line-height: 40px;
background: #eee;
outline: 1px solid #ccc;
}
#modalbox p {
font:bold 20px Arial;
margin-top: 10px;
color: #eee;
}
#modalbox input {
font:bold 20px Arial;
margin-top: 5px;
color: #eee;
}
.send {
float: left;
margin: 10px 0 0 100px;
background: red;
padding: 3px;
font: bold 20px Arial;
color: #fff;
text-decoration: none;
}
JavaScript
$(function() {
$('a.button').click(function(){
$('#modalbox h3').html($("#block h2") ? );
});
});