Your html isn't valid.
* A dl cannot contain a div directly as you've shown, only dts and dds.
* The dt and dd elements inside the div#bar need to be directly inside the
dl. They can't have a div as a parent.
* The dt and dd elements don't close immediately when you put a closing
slash in the opening tag. If you want to have them be empty and close them
immediately, change

<dt />

to

<dt></dt>

otherwise the browser ignores the slash in the opening tag and waits for
some parsing rule to close the element. For more on that, see
http://groups.google.com/group/jquery-en/browse_thread/thread/bef63592011861ba

By the time the browser's html parser is done with it, your html might look
something like this:

<div id="foo">
  <dl>
    <dt>
      <div id="bar"></div>
    </dt>
    <dt></dt>
    <dd></dd>
    <dt></dt>
    <dd id="baz"></dd>
  </dl>
</div>

which based on the html you've shared is a lot different than what you
started with.

- Richard

On Wed, Dec 16, 2009 at 6:39 PM, cewing <cew...@u.washington.edu> wrote:

> Hi all,  I've got a bit of HTML with the following structure:
>
> <div id="foo">
>  <dl>
>    <dt />
>    <div id="bar">
>      <dt />
>      <dd />
>      <dt />
>      <dd id="baz"/>
>    </div>
>  </dl>
> </div>
>
> in IE6 and IE7 $("dd#baz").parents() returns an object with 2 nodes in
> it, the dl and div#foo.  it does not contain div#bar.  I assume this
> is due to a stricter interpretation of proper DOM structure in IE6 and
> IE7 than in FF, Safari, Chrome, Opera, or even IE8 (where div#bar _is_
> present).
>
> I need to find div#bar.  Can someone suggest a traversal-based
> workaround to getting there from dd#baz that will work in IE6 and
> IE7?  The problem with non-traversal based solutions is that the
> entire structure you see here may be nested inside each of the dd
> elements, and if so, I'd need to find the div#bar _closest_ in the
> parents hierarchy to the dd from which I begin.
>
> If absolutely necessary, I can scrap dl structure and go with a more
> pure div-based structure, but I'm trying to hook into some automatic
> styling in my chosen framework and that is hung on dl elements.
>
> Any suggestions?
>

Reply via email to