2 回答
TA贡献1810条经验 获得超4个赞
简单写了一下,凑合看
css:
#div_add{
border: 1px solid #000;
width: 500px;
}
.div_list{
width: 200px;
height: 20px;
background-color: greenyellow;
border: 1px solid #ccc;
}
html
<input type="button" id="btn1" value="增加"/>
<input type="button" id="btn2" value="清空"/>
<div id="div_add"></div>
js:
<script src="../jquery.min.js"></script>
var addHTML = '<div class="div_list"></div>';
//$('#div_add').append(addHTML);
var time = 0;
$('#btn1').click(function (e) {
time++;
if(time < 6){
$('#div_add').append(addHTML);
}
if(time === 5){
$(this).attr("disabled", "disabled");
}
});
$('#btn2').click(function (e) {
$('#div_add').empty();
$('#btn1').removeAttr('disabled');
time = 0;
})
添加回答
举报