On 18 abr, 19:48, JAT <[EMAIL PROTECTED]> wrote:

> [...]
> I've problems to select a certain element on code HTML generated by
> php.
> [...]
> ,----[ HTML Code ]
> | <div class="box-general">
> |      <div class="box-articles">
> |           [...]
> |           {Article options linked with <a> or <img> tags}
> |           [...]
> |           <img class="box-slide" id="article-id">
> |           [...]
> |           <div class="box-slide-hidden" id="article-id">
> |                <div class="article-slide">
> |                     {Info about article selected}
> |                </div>
> |           </div>
> |      </div>
> | </div>
> `----
>
> ,----[ CSS Code ]
> | [...]
> | .box-slide-hidden {
> |     display:none
> | }
> | [...]
> `----
>
> ,----[ jQuery Code ]
> | $("img.box-slide").click(function() {
> |      // Get unique id;
> |      var $match-img-id = $(this).attr('id');
> |
> |      $(div.box-slide-hidden).each(function (i){
> |          // Get unique id to compare with $match-img-id
> |          // and, if true, run slide effect.
> |          var $match-div-id = $(this).eq(i).attr('id')
> |          [...]
> |      });
> | });
> `----
>
> This code works but only shows the first div.box-slide-hidden
> occurrence.
> [...]
> How can I get a right loop to show right reference only?

Finally I've get it, simple and beauty.

,----[ jQuery Code ]
| $("img.box-slide").click(function() {
|     $('~ div.box-slide-hidden:first', this).slideToggle('slow');
| });
`----

Greetings.

Reply via email to