954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

jQuery, list elements in the section

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?

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

I think I understand what you were trying to say:

var ids = [];
$('#rightList > li').each(function(el) {
  ids.push(el.id);
});
ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

Thanx ShawnPlus I will try it

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

Working as expected. Thank you ShawnPlus

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You