2013-02-11 54 views
0

我一直在與這些爲兩天,無法弄清楚如何做到這一點...請諮詢JQuery的舉措不能正常工作下一個元素

http://jsfiddle.net/kbspot/fjVhY/

在底部顯示笨手笨腳的時候,用戶點擊拇指大預覽會顯示...我得到它的工作

問題: 另一件我想補充的是,當用戶點擊大預覽時,將選擇NEXT拇指(底部面板) 。但它沒有按照我的要求工作,Next拇指未被選中。

//Click on thumbnail (this is working perfectly) 
$(".panel-bottom li").click(function() { 
    var $activetab = $('li.active');   
    //$activetab.('IMG').hide(); 
    $activetab.removeClass('active');  
    $(this).addClass('active'); 

    //$(this).next().css({'border': '2px solid red'}); 
}); 

//Large Preview click (this is the problem) 
$("li.active .container").click(function() { 
    //alert($(this).parent().html()); 
    var $activetab = $(this);  
    var $nexttab = $activetab.next(); 

    $(this).removeClass();  
    $nexttab.addClass("active"); 
}); 

對不起,林不知道該如何解釋但是我相信你得到它,希望

+0

MildlyInteresting&Phil Cook,謝謝你...檢查你的代碼後,我發現了問題。對不起,小提琴。 [code] // Large Preview click $(「。container」)。click(function(){ var $ activetab = $(this).parent(); \t var $ nexttab = $ activetab.next(); $ activetab.removeClass(「active」); $ nexttab.addClass(「active」); return false; //這會阻止它回到上一個元素 }}; [code] – 2013-02-12 09:48:24

回答

0

小提琴心不是正確地顯示出來對我來說,但是從這裏的代碼,它看起來像在大預覽點擊,$activetab不應該是li.active .container元素,但其父母li.active,如在第一部分?

//Large Preview click (this is the problem) 
$("li.active .container").click(function() { 
    //alert($(this).parent().html()); 
    var $activetab = $(this).parent(); // Updated this line  
    var $nexttab = $activetab.next(); 

    $(this).removeClass();  
    $nexttab.addClass("active"); 
}); 
0

你的js小提琴有點破,因爲它看起來像圖像指向你的本地發展。

<img src="http://lensamaya/basic/photo/images/1.jpg" alt="From off a hill whose concave womb reworded" /> 

但是我想我可以看到你的問題,因爲你正在下降到容器div並試圖轉向下一個元素。然而,你需要先升到你的鋰元素的水平,然後再下降。

這樣的事情會起作用。

$("li.active .container").click(function() { 
    //alert($(this).parent().html()); 
    var $activetab = $(this);  
    var $nexttab = $activetab.parent().next().children('.container'); 

    $(this).removeClass();  
    $nexttab.addClass("active"); 
});