Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Find and List all LI elements within a UL within a specific DIV

I have 3 Columns of ULs each a Dynamic UL container that can have anywhere from 0-9 LI containers (eventually more). All my LI elements have an attribute "rel" which I am trying to ultimately find that attribute and use it for something else on all LI elements within that parent DIV. I do eventually want to find more based on each but for not the very least the rel.. Any Ideas how I can achieve that with jQuery? Example:

<ul id="column1">    <li rel="1">Info</li>    <li rel="2">Info</li>    <li rel="3">Info</li> </ul> <ul id="column2">    <li rel="4">Info</li>    <li rel="5">Info</li>    <li rel="6">Info</li> </ul> <ul id="column3">    <li rel="7">Info</li>    <li rel="8">Info</li>    <li rel="9">Info</li> </ul> 

these elements are all sortable as well. So when I get a list of them I want to also keep them in the order they were found from top to bottom of each column.

I have tried find(), parent(), and similar, maybe I am approaching it wrong. But its still worth mentioning to help come up with an idea

like image 781
chris Avatar asked Aug 18 '11 03:08

chris


1 Answers

Are you thinking about something like this?

$('ul li').each(function(i) {    $(this).attr('rel'); // This is your rel value }); 
like image 175
pixelfreak Avatar answered Oct 05 '22 20:10

pixelfreak