문제

I am trying to access the DOM element for 'show more topics' from the haml file

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

I tried to run the following code:

$('.topics .show_more_topics')

However I am getting back an empty array [].

How can I retrieve the 'show more topics' element?

도움이 되었습니까?

해결책

The link with class show_more_topics is a sibling of the topics list (see how they're indented the same?), while the selector .topics .show_more_topics selects an element with the class show_more_topics that's a descendent of an element with the class topics.

You just want $('.show_more_topics').

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top