我想使用jQuery選擇器(這個)來獲取嵌套在同一級別的圖像。 只是語法錯誤,任何幫助將不勝感激。謝謝!jquery選擇器+語法
$(this).addClass('on');
$(this img).slideUp('fast');
$(this img.accordionButtonActive).slideDown('fast');
我想使用jQuery選擇器(這個)來獲取嵌套在同一級別的圖像。 只是語法錯誤,任何幫助將不勝感激。謝謝!jquery選擇器+語法
$(this).addClass('on');
$(this img).slideUp('fast');
$(this img.accordionButtonActive).slideDown('fast');
我想你想的實現這樣的:
http://jsfiddle.net/expertCode/zBrhH/
使用:
$(this).addClass('on');
$('img', this).slideUp('fast');
$('img.accordionButtonActive', this).slideDown('fast');
我改變了一些活動了。試試吧;)
非常感謝,我喜歡事件的變化。 我只是試圖寫一個if語句來檢查'on'並顯示圖像/刪除其他。感謝您的洞察力和主動性! – patrick
您可以使用[toogle](http://api.jquery.com/toggle/),[toggleClass](http://api.jquery.com/toggleClass/)和[slideToggle ](http://api.jquery.com/slideToggle/)。看到這裏的結果:[http://jsfiddle.net/expertCode/zBrhH/4/](http://jsfiddle.net/expertCode/zBrhH/4/);) – expertCode
修復了第一次打開的類'開'手風琴默認:[http://jsfiddle.net/expertCode/zBrhH/8/](http://jsfiddle.net/expertCode/zBrhH/8/) – expertCode
你不能這樣做$(此圖片)。但是你可以通過它定義範圍的第2參數,試試這個:
$('img', this)...
$(this img).slideUp('fast');
應該
$(this).find("img").slideUp('fast');
演示,與工作手風琴:http://jsfiddle.net/zBrhH/2/
檢查他的jsfiddle;它非常全面。 – Ryre