Sar*_*M P 0 html javascript jquery jquery-ui
这是我的代码:
<script type="text/javascript">
$(document).ready(function(){
$('.toAdd').hide();
$('#add').click(function () {
var i = 0;
$('.toAdd').each(function () {
if ($(this).show()) {
i++;
}
});
});
});
</script>
<div id=add><input type="button" value="click"/>
</div>
<div id="toAdd">
<label>1</label>
</div>
<div id="toAdd">
<label>2</label>
</div>
<div id="toAdd">
<label>3</label>
</div>
<div id="toAdd">
<label>4</label>
</div>
Run Code Online (Sandbox Code Playgroud)
在此代码中,我需要为每个点击事件一个一个显示div,但它不起作用?
ID必须是唯一的,请改用类。
$('.toAdd').hide();
var count = 0;
$('input').on('click',function(){
$('.toAdd:eq('+count+')').show();
count++;
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3668 次 |
| 最近记录: |