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...?
- <div>
- <div>
- <div>
- <div>
- <img />
- </div>
- </div>
- <div class="myDiv"></div>
- <div>
- <div>
- <div>
- <div>
- <img />
- </div>
- </div>
- <div class="myDiv"></div>
- <div>
- <div>
- <div>
- <div>
- <img />
- </div>
- </div>
- <div class="myDiv"></div>
- <div>
<div>