[問題] (jQuery)將剩餘的div物件顯示

作者: qazsd ( )   2015-12-01 13:51:05
<style>
.aa {
display:block;
}
</style>
</head>
<body>
<input id="btnTest" value="隱藏" type="button">
<div class="aa">itme 1</div>
<div class="aa">itme 2</div>
<div class="aa">itme 3</div>
<div class="aa">itme 4</div>
<div class="aa">itme 5</div>
<script type="text/javascript">
$("#btnTest").click(function(){
$('div.aa[display:block]:first').fadeOut(1000);
});
</script>
</body>
預期是每點一次"隱藏"按鈕,就可以將第一個類別為"aa"的Div fadeOut
但上述程式點了第一次後,第一個Div有fadeOut
但再次點擊,就沒有將剩餘的Div fadeOut了
有沒有大大可以指出一下問題出在哪?
作者: irena4 (Irena)   2015-12-01 14:57:00
http://jsbin.com/zucimo/edit?html,js,output雖然頁面上是消失,但div的dom還是存在頁面上,所以用:first 就沒用,我這邊改用:visible:first
作者: sa0124 ((恩恩))   2015-12-01 16:06:00
又學到一個新用法 感謝樓上

Links booklink

Contact Us: admin [ a t ] ucptt.com