Searching element BEFORE another element

Searching element BEFORE another element

Assume I have the following code

  1. <div class="top">
  2. <div>.aaa...</div>
    <div class="foobar">.bbb..</div>
    <div>.ccc..</div>
    </div>


How can I address with jQuery the <div> element BEFORE the <div> element with class="foobar"?

With pure CSS this isn't possible AFAIK.

But in Javascript it should be possible by a function like previousElementSibling().

Maybe there is a shorter, better way in jQuery?


 Peter