Minirock Minirock - 2 years ago 82
Javascript Question

Accessing a specific element from the DOM

Morning, I have some HTML like this:

<ul class="Menu1">
<li>I1</li>
<li>I2</li>
</ul>
<ul class="Menu2">
<li>I3</li>
<li>I4</li>
</ul>


I want to access all the
li
from a specific
ul
(Menu 2 for example).
Sorry, I know this is really basic but what am I supposed to use instead of
$("li")
?

Answer Source

IF the Menu and 2 are 2 separate class you can go with -

$('.Menu.2 li')

IF the Menu and 2 are 1 class that is Menu2 you can go with -

$('.Menu2 li')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download