开发者

"get a sibbling" problem

开发者 https://www.devze.com 2023-03-12 13:54 出处:网络
i am struggling with the following : I am loading news messages from a other html page in my site : on first html page i have :

i am struggling with the following :

I am loading news messages from a other html page in my site :

on first html page i have :

<div class="post_box">
      <div class="newsexcerpt1"></div>
</div>
<div class="post_box">
      <div class="newsexcerpt2"></div>
</div>

on my second page(news1.html) i have :

<div id="nieuws">
  <div class="news">
        <div class="开发者_开发百科newsexcerpt">bla die bla die bla </div>
  </div>
  <div class="news">
       <div class="newsexcerpt">bla die bla die bla </div>
  </div>
</div>

I try to get it working with :

$('.newsexcerpt1').load('news1.html .newsexcerpt:first');
$('.newsexcerpt2').load('news1.html .newsexcerpt').next('news1.html .newsexcerpt:first');

The first line of $ is running smoothly , but get the second is the big problem

how can i get the next .newsexcerpt ?

is there someone who can help me ?

Thnx


You just want a different selector here. To get the "nth" match of a selector, use the :eq() selector, like this:

$('.newsexcerpt1').load('news1.html .newsexcerpt:first');
$('.newsexcerpt2').load('news1.html .newsexcerpt:eq(1)');
0

精彩评论

暂无评论...
验证码 换一张
取 消