D4Ly
asked on
referencing elements without ID's
If I have HTML like this
<ul>
<li><a href="javascript://" title="Toggle" onclick="menu_toggle();">1 </a>
<ul id="one">
<li>1a</li>
<li>1b</li>
<li>1c</li>
<li>1d</li>
</ul>
</li>
<li><a href="javascript://" title="Toggle" onclick="menu_toggle();">2 </a>
<ul id="two">
<li>2a</li>
<li>2b</li>
<li>2c</li>
</ul>
</li>
</ul>
What is the best way to do the following:
1) Pass a refrence to the menu_toggle function for the <a> element being clicked.
2) Select the parent element (the <li> that the link is nested in)
3) select the <ul> within that <li>
The addition of id's and such is not allowed!! Thanks!!
<ul>
<li><a href="javascript://" title="Toggle" onclick="menu_toggle();">1
<ul id="one">
<li>1a</li>
<li>1b</li>
<li>1c</li>
<li>1d</li>
</ul>
</li>
<li><a href="javascript://" title="Toggle" onclick="menu_toggle();">2
<ul id="two">
<li>2a</li>
<li>2b</li>
<li>2c</li>
</ul>
</li>
</ul>
What is the best way to do the following:
1) Pass a refrence to the menu_toggle function for the <a> element being clicked.
2) Select the parent element (the <li> that the link is nested in)
3) select the <ul> within that <li>
The addition of id's and such is not allowed!! Thanks!!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Smaccari-
Perfect! And the next step for me was in fact to add the display :) Thanks much, have a great day. I will give some credit to pravinasar, weighted to you for the simpler solution. Thanks!!!
- D4
Perfect! And the next step for me was in fact to add the display :) Thanks much, have a great day. I will give some credit to pravinasar, weighted to you for the simpler solution. Thanks!!!
- D4
<a href="javascript:void(0);"
Would help to see your toggle_menu() function but rebuild it something like:
function menu_toggle (linkID) {
if (linkID == 1) {
// do this
} else if (linkID == 2) {
//do this
}
}
If I'm missing your point altogether...please provide more details of whay you're trying to accomplish.
-Sam