beginner question about the use of .has(), if and .parent()

beginner question about the use of .has(), if and .parent()

My question is the following: I have got a little CMS (with a WYSIWYG editor) for somebody who is not familiar with HTML and CSS at all. That's why I simply can't adress classes/ids/...

The issue:
As I cannot adress classes/ids I thought I would search for a certain pattern
  1. <ul>
  2.       <li>
  3.             (<a>)<img />(</a>)
  4.             <div></div>
  5.       </li>
  6. </ul>
now all I want to do is to do .addClass("info") on every <div> that is in the pattern. I already tried
  1. for(var i=0; i < $("img").length; i++) {
            if($("img")[i].parent().parent().parent("ul") || $("img")[i].parent().parent("ul")) {
                if($("img")[i].parent().parent().$("div") || $("img")[i].parent().$("div")) {
                    $("img")[i].parent().parent().$("div")[0].addClass("info");
                    $("img")[i].parent().$("div")[0].addClass("info");
                }
            }
        }






but I guess this is somewhat of a nonsense (yeah sorry, I simply am too much into PHP/AS, I do not quite get this chaining thing :/ )

Then I tried this
  1.     $("#main ul li img").parent().has("div").addClass("info");
        $("#main ul li a img").parent().parent().has("div").addClass("info");
but this doesn't work either (info class has not been appplied).

I guess there is a more sophisticated solution as well (maybe with siblings?), one is intended to figure out after reading all the tutorials, but I read them and didn't come up with anything but this nonsense :S

Looking forward to your answers, Peter