0
<div class='images'></div>
<div class='toload'></div>
<div class='sky'></div>
<select class="select01">
    <option value="winners_02/2015.php">2015 - DOPS 6</option>
    <option value="winners_02/2014.php">2014 - DOPS 5</option>
    <option value="winners_02/2013.php">2013 - DOPS 4</option>
</select>

<div class='images'></div>
<div class='sea'></div>
<div class='toload'></div>  // target

JS

$('.select01').change(function(){
    var a = $(this).val();
    //something like: next().first(`toload`).load(a);
});

I have various situations before and after each of select01.
Changing the select01 I need to affect only on first next div named toload.
In the above example it is marked by target.

qadenza
  • 9,025
  • 18
  • 73
  • 126

1 Answers1

4

You can use nextAll() and match only first one:

$(this).nextAll('.toload').first().load(a);

Or if there is no other (not like in your specific case) .toLoad sibling of specific clicked .select01, then use:

$(this).siblings('.toload').load(a);
A. Wolff
  • 74,033
  • 9
  • 94
  • 155
  • 1
    in his markup there 2 element with class `toload` one before select the other after i think you need to use `.next()` because he wants the next one. OP says `first next div named toload` – guradio Aug 30 '16 at 08:40
  • 1
    @guradio Ya thx! I missed it but still keep second example which still stipulate that `if there is no other .toLoad sibling` – A. Wolff Aug 30 '16 at 08:41