Class 如何从haml文档中检索类元素
我正在尝试从haml文件访问“显示更多主题”的DOM元素Class 如何从haml文档中检索类元素,class,dom,haml,Class,Dom,Haml,我正在尝试从haml文件访问“显示更多主题”的DOM元素 #profile-wrapper.container-fluid .sidebar .profile %h4 Interests %ul.topics %a.show_more_topics.hide Show More 我尝试运行以下代码: $('.topics .show_more_topics') 但是,我将返回一个空数组[] 如何检索“show more topics”元素?与classsh
#profile-wrapper.container-fluid
.sidebar
.profile
%h4 Interests
%ul.topics
%a.show_more_topics.hide Show More
我尝试运行以下代码:
$('.topics .show_more_topics')
但是,我将返回一个空数组[]
如何检索“show more topics”元素?与class
show more\u topics
的链接是topics
列表的同级链接(请参见它们是如何缩进的?),而选择器.topics.show_more_topics
选择类为show_more_topics
的元素,该元素是类为topics
的元素的后代
您只需要$('.show\u more\u topics')