0

私を助けてくれてありがとう、私はこのコードを手に入れましたが、もっと必要です。

ページがダウンロードされると、div の一部が非表示になりますが、画像をクリックすると表示されます。

BUT:その画像の近くにテキストを書き、タグを付けたいのですが、すべてクラッシュします。

ビュー内の私のコード:

  <% @websites.each do |website| %>
   <div class="sub">
<%= link_to(image_tag("/images/caret-horizontal.png", id: "caret-horizontal"), '#') %>
     <%= website.name %>//when I put this in tag show doesn't work
     <div class="desc">
       <%= website.url %> 
   <%= website.category %> 
    <%= website.language %>
   </div>
    </div>
         <% end %>

私のJavaScript:

 $(".sub a").click(function() {
    $(this).next("div").show("medium");
});

誰かが私を修正したり、その方法を説明したりできますか?

4

1 に答える 1

1

div の前にリンクの横にタグを配置すると、next()正しく機能しませんか??

ドキュメンテーション:

Get the immediately following sibling of each element in the set of matched elements.

.siblings()...の代わりに使用するnext()とうまくいきます...

于 2012-06-12T15:00:24.950 に答える