How to find a div in DOM

How to find a div in DOM

I know it sounds simple, however I've trying all day and could not manage to do it...
My code is similar to the one below. I need to find the closest "myDiv" to the img clicked.
My problem is that the actual stracture of the page is very compicated and not always the same. This is a ASP.NET control that can be placed anywhere inside body.

Since I could not make it work with .find, .next, .nextUntil, etc, I tried to search each parent and if it had a div.myDiv to do the job. However for some reason, it always finds the top in the page...

Can anybody help...?

  1. <div>
  2.       <div>
  3.             <div>
  4.                   <div>
  5.                         <img />
  6.                   </div>
  7.             </div>
  8.             <div class="myDiv"></div>
  9.       <div>
  10.       <div>
  11.             <div>
  12.                   <div>
  13.                         <img />
  14.                   </div>
  15.             </div>
  16.             <div class="myDiv"></div>
  17.       <div>
  18.       <div>
  19.             <div>
  20.                   <div>
  21.                         <img />
  22.                   </div>
  23.             </div>
  24.             <div class="myDiv"></div>
  25.       <div>
<div>