我使用jQuery將一個.current類添加到構建到wordpress插件中的一系列縮略圖中。我不熟悉MooTools,所以我嘗試使用jQuery來添加.current類。我正在做的是將.current類添加到第一個縮略圖div,並在點擊後移除該類。jQuery將類添加到第一項直到另一個被點擊
這是我到目前爲止有:
$('div.thumb img').click(function() { // When we click on something in the filter menu
$(this).css('outline','none'); // Remove css outline
$('div.thumb').removeClass('current'); // Removes the current class from where it is now
$(this).parent().addClass('current'); // Adds the current class to the item we clicked on
return false;
});
這確實增加了類中的項目被點擊,但最初的縮略圖不突出了。所以我試圖設置初始縮略圖,所以它有一個.current類,直到點擊另一個縮略圖。
任何幫助將不勝感激。
謝謝!
可能有助於 http://api.jquery.com/first-child-selector/ – 2013-03-04 05:49:15
你能夠就'jsfiddle'樣本,並顯示什麼你想改變? – Martin 2013-03-04 05:50:22