Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting specific element

Status
Not open for further replies.

viperous

Programmer
Joined
Jun 1, 2006
Messages
3
Location
CA
I manage to get an example of a drag and drop in javascript working. ( )

I'm not trying to apply this technique to my project. Though I'm getting stumped on my HTML hierarchy.

Here's my HTML code
Code:
<div id="bottom_content">
   <div id="left_container">
      <div>
         [b]<ul class="handle">[/b]
            <li class="box_name">Photo Pool</li>
         </ul>
         <p>Text</p>
      </div>
   </div>
   <div id="left_container">
      <div>
         <ul class="handle">
            <li class="box_name">Photo Pool</li>
        </ul>
        <p>Text</p>
     </div>
   </div>
So pretty much, following the example shown in I'm trying to get down to my <ul>. How would I go by doing that?

I've tried document.getElementByTagName("ul") but no gold. I am able to get to that lone <div> before my <ul> fine...but for this project, it's requiring me to dig a bit deeper.

Any help apprecieated. Thanks
 
I've tried document.getElementByTagName("ul") but no gold.

There is no such call as "getElementByTagName"... it is "getElement[!]s[/!]ByTagName". This returns an array of elements, so you would need to specify which UL you were after:

Code:
document.getElementsByTagName("ul")[!][0][/!]

or, if there were an unknown number of UL elements before your DIV, you could narrow it down further:

Code:
document.getElementById('left_container').document.getElementsByTagName("ul")[0]
Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Actually, I figured it out. Like Pete said, I don't think I was clear on my question. Sorry for that.

Turns out that I wasn't getting high enough in my heiarchy. I just added in one more parentNode to reach left_container.

Code:
item.parentNode.parentNode.myfunction();

I'm I'm trying to figure out why my function isn't working properly. I'll add the entire code once I get home.

Thanks for the help so far guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top