I will keep it simple. I need to list id of every element in given section.
Example

<div id="leftSide">
    <ul id="leftList">
        <li id="item1"item 1</li>
        <li id="item2"item 2</li>
        <li id="item3"item 3</li>
        <li id="item4"item 4</li>
        <li id="item5"item 5</li>
        <li id="item6"item 6</li>
    </ul>
</div>
<div id="rightSide">
    <ul id="rightList">
        <li id="item2"item 2</li>
        <li id="item4"item 4</li>
        <li id="item6"item 6</li>
    </ul>
</div>

I need to get IDs for "li" items on the "rightSide" container.
How to?

Recommended Answers

All 3 Replies

I think I understand what you were trying to say:

var ids = [];
$('#rightList > li').each(function(el) {
  ids.push(el.id);
});
commented: Very helpful reply +12
commented: Perfect answer :) +3

Thanx ShawnPlus I will try it

Working as expected. Thank you ShawnPlus

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.