2011-11-23 28 views
0

我試圖訪問DOM元素檢索類元素「表現出更多的主題」從HAML文件如何從HAML文件

#profile-wrapper.container-fluid 
    .sidebar 
    .profile 
    %h4 Interests 
    %ul.topics 
    %a.show_more_topics.hide Show More 

我試圖運行下面的代碼:

$('.topics .show_more_topics') 

但是我回到一個空數組[]。

如何檢索'顯示更多主題'元素?

回答

2

show_more_topics類的聯繫是topics列表(可以看到他們如何縮進一樣?)的兄弟,而選擇.topics .show_more_topics選擇具有類show_more_topics這與元素的後代元素類topics

你只想要$('.show_more_topics')