Solved

Use jQuery to remove rows from table

Posted on 2011-09-29
7
336 Views
Last Modified: 2012-08-14
Is there a way to HIDE all rows that don't have

"Pick-up Instore"

as the  inner text for lblDisplay?



		<table cellspacing="0" cellpadding="3" rules="cols" border="1" id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping" style="background-color:Transparent;font-size:12px;height:20px;width:300px;border-collapse:collapse;">
			<tr style="color:White;background-color:Gray;">

				<th align="left" scope="col">Select Shipping Method</th><th align="right" scope="col">Amount</th><th align="right" scope="col">&nbsp;</th>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$0')">
				<td>
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl02_lblDisplay">USPS Media Mail</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl02_lblAmount">$5.95</span>
</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$0')"></a></td>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$1')">
				<td>

<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl03_lblDisplay">USPS Express MAil</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl03_lblAmount">$8.45</span>
</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$1')"></a></td>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$2')">
				<td>
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl04_lblDisplay">FedEx Second Day Air</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl04_lblAmount">$12.00</span>
</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$2')"></a></td>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$3')">

				<td>
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl05_lblDisplay">FedEx Overnight</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl05_lblAmount">$20.00</span>
</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$3')"></a></td>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$4')">
				<td>
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl06_lblDisplay">Pick-up Instore</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl06_lblAmount">$0.00</span>

</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$4')"></a></td>
			</tr>
		</table>

Open in new window




This is what the table looks like at runtime:

 ship method
0
Comment
Question by:knowlton
  • 4
  • 3
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36817143
Use : $("tr:not(:contains('Pick-up Instore')):not(:eq(0))","table").hide();
Test page : http://jsfiddle.net/v6W9K/

Or: $("tr:not(:contains('Pick-up Instore'))","table").hide();
Test page : http://jsfiddle.net/v6W9K/1/

0
 
LVL 5

Author Comment

by:knowlton
ID: 36817275
I need it to only operate on tables with the following in their id:

table tag id contains gvShipping
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 36817277
thx
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 5

Author Comment

by:knowlton
ID: 36817292
Is this correct?

$("tr:not(:contains('Pick-up Instore'))", "table[id*='gvShipping']").hide();
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36817313
look fine, you're using the contain selector

 "table[id*='gvShipping']"

<< a table where where its ID contains gvShipping >>
0
 
LVL 5

Author Comment

by:knowlton
ID: 36817335
Thanks again!!!!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36817337
you're welcome, have fun!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now