Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

JQUERY HIDE TABLE ROW

I Guess In to break this question up into smaller solutions?  

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27385721.html

Checkbox selectors replace class active with hidden or remove class active on span tags.

Using JQuery, how can I hide a table row if it does not contain span tags with class active?

 <tr id="row1">
    <td class="student">John</td>
    <td class="wk1"><span class="gradeblock grade-A xtra-hmk active">A*</span></td>
    <td class="wk2"><span class="gradeblock grade-A not-xtra-hmk active">A</span></td>
    <td class="wk3"><span class="gradeblock grade-A not-xtra-hmk active">A</span></td>
</tr>
 <tr id="row2">
    <td class="student">John</td>
    <td class="wk1"><span class="gradeblock grade-A xtra-hmk">A*</span></td>
    <td class="wk2"><span class="gradeblock grade-A not-xtra-hmk">A</span></td>
    <td class="wk3"><span class="gradeblock grade-A not-xtra-hmk">A</span></td>
</tr>

In the above example, row 2 would be hidden.

0
pathfinder11
Asked:
pathfinder11
  • 6
  • 4
1 Solution
 
leakim971PluritechnicianCommented:
use : $("span:not('.active')", "#table_id").closest("tr").hide();

where  table_id is your table id (may help if you've more than one table in your page)

test page : http://jsfiddle.net/WYq7b/
0
 
pathfinder11Author Commented:
leakim971:

Thanks, that's great. My problem is trying to make this solution work:

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27385721.html

If you can help with that, that would be awesome. Is there a method which will work on if visible rather than .active? I think that might make things work using this in the other solution?  
0
 
pathfinder11Author Commented:
leakim971:

After fiddling with your solution, the idea is if all span tags are not active rather than if any span tags are not active... not sure if that's how your code is working.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
leakim971PluritechnicianCommented:
If this question is answered, please close it.
0
 
leakim971PluritechnicianCommented:
<< In the above example, row 2 would be hidden. >>

It's the case for me : http://jsfiddle.net/WYq7b/4/
0
 
pathfinder11Author Commented:
How about this example?

<table id="table_id">
    <tr id="row1">
    <td class="student">John</td>
    <td class="wk1"><span class="gradeblock grade-A xtra-hmk active">A*</span></td>
    <td class="wk2"><span class="gradeblock grade-A not-xtra-hmk active">A</span></td>
    <td class="wk3"><span class="gradeblock grade-A not-xtra-hmk active">A</span></td>
</tr>
 <tr id="row2">
    <td class="student">John</td>
    <td class="wk1"><span class="gradeblock grade-A xtra-hmk active">A*</span></td>
    <td class="wk2"><span class="gradeblock grade-A not-xtra-hmk">A</span></td>
    <td class="wk3"><span class="gradeblock grade-A not-xtra-hmk active">A</span></td>
</tr>
</table>

Deviates from the above? or just a logical assumed condition given the reference link?
0
 
leakim971PluritechnicianCommented:
0
 
pathfinder11Author Commented:
Well in this case, it not supposed work, if a span is active, the data in the row is valid against the filter applied. So to indeed clarify where perhaps I should have to begin with, tr which contain no active tags would be hidden those which contain 1 or more active tags would not be hidden.

Better yet, hide tr which contains all span tags with attrib not visible/display: none, else show tr

0
 
leakim971PluritechnicianCommented:
Use : http://jsfiddle.net/WYq7b/6/
$("tr", "#table_id").each(function() {
    if( $("span.active", this).length == 0 ) $(this).hide();
})

Open in new window

0
 
RobOwner (Aidellio)Commented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
leakim971PluritechnicianCommented:
I think this one is answered
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now