Solved

JQuery selector question

Posted on 2013-02-05
5
292 Views
Last Modified: 2013-02-05
I have the following HTML Table
<table class="display" style="width: 1000px;" id="failoverServers">
	<thead>
		<tr>
			<th class="row_selector_head"> <input type='checkbox' class='select_all_chkbx'/></th>
			<th><div>{% trans "IP ADDRESS" %}</div></th>
			<th><div>{% trans "VIRTUAL IP ADDRESS" %}</div></th>
			<th><div>{% trans "USERNAME" %}</div></th>
			<th><div></div></th>
		</tr>
	</thead>

	<tbody>
	{% for i in list %}
		<tr rel="{{ i.id }}">
			<td class="row_selector"><input type='checkbox'/></td>
			<td rel="ip">{{ i.ipAddress }}</td>
			<td rel="virtualIP">{{ i.virtualIpAddress }}</td>
			<td rel="username">{{ i.username }}</td>
			
		</tr>
	{% endfor %}

	</tbody>
</table>

Open in new window


If I do the following:
           
      var list = "";
	            $('#failoverServers td.row_selector.selected').each(function() {
		        var row = $(this).closest('tr');
		        var id = row.attr('rel');
		        list += id + " ";			
		    });

Open in new window


Then I have a list of the numbers in the very first checkbox column.

I want to get a list of the following from the table:
            
<td rel="ip">{{ i.ipAddress }}</td>

Open in new window


What jquery selector do I use for this??

Thanks
0
Comment
Question by:Wanting2LearnMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 38856601
var list = "";
                  $('#failoverServers td.row_selector.selected').each(function() {
                    var row = $(this).closest('tr');
                    var id = row.find("td[rel='ip']").text();
                    list += id + " ";                  
                });
0
 

Author Comment

by:Wanting2LearnMan
ID: 38856641
Hi leakim971, your answer works, just one more thing:
What I want to do is to just get all the ip items from the table whether they are selected or now (Just get all them, they dont have to be selected)

How do I do this?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 38856655
So remove << .selected >>
var list = "";
                  $('#failoverServers td.row_selector').each(function() {
                    var row = $(this).closest('tr');
                    var id = row.find("td[rel='ip']").text();
                    list += id + " ";                  
                });

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 38856670
or just :
var list = [];
$("td[rel='ip']", '#failoverServers').each(function() {  list.push( $(this).text() ); })
list.join(" ");

Open in new window

0
 

Author Closing Comment

by:Wanting2LearnMan
ID: 38856803
Thanks :)
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question