2016-03-15 18 views
-2

當我點擊一個鏈接時,所有的活動類都被刪除,但是活動類沒有添加到這個點擊的對象上!爲什麼css類沒有在每個jQuery上加上

$(".bootgrid-table th > .column-header-anchor > span.text + span.jquery-bootgrid-arrow").prev("span.text").addClass("active"); 

$('.bootgrid-table th > a').click(function() { 
    $('.bootgrid-table th > a').not(this).each(function() { 
     $(this).find("span.jquery-bootgrid-arrow").prev("span.text").removeClass("active"); 
    }); 

    $(this).find("span.jquery-bootgrid-arrow").prev("span.text").addClass("active"); 

}); 
+1

顯示你的HTML過了,請創建[MCVE。 –

+0

@Jamiec它是'[mcve]'。 –

+1

@PraveenKumar我知道,這是一個錯字。但看到你已經發布它,我剛剛刪除。 – Jamiec

回答

0

試試這個:

$('.bootgrid-table th > a').click(function() { 
     $(".active").removeClass("active"); 

     $(this).find("span.jquery-bootgrid-arrow").prev("span.text").addClass("active"); 

}); 
+0

不工作。當我第一次點擊時,文本不加粗我再次點擊,有大膽。課堂活動做文字大膽 –

相關問題