Avatar of pathfinder11
pathfinder11

asked on 

JQUERY HIDE TABLE ROW

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

https://www.experts-exchange.com/questions/27385721/JQUERY-SHOW-HIDE-TABLE-CONTENT-ROWS-COLUMNS.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.

JavaScript

Avatar of undefined
Last Comment
leakim971
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of pathfinder11
pathfinder11

ASKER

leakim971:

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

https://www.experts-exchange.com/questions/27385721/JQUERY-SHOW-HIDE-TABLE-CONTENT-ROWS-COLUMNS.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?  
Avatar of pathfinder11
pathfinder11

ASKER

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.
Avatar of leakim971
leakim971
Flag of Guadeloupe image

If this question is answered, please close it.
Avatar of leakim971
leakim971
Flag of Guadeloupe image

<< In the above example, row 2 would be hidden. >>

It's the case for me : http://jsfiddle.net/WYq7b/4/
Avatar of pathfinder11
pathfinder11

ASKER

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?
Avatar of pathfinder11
pathfinder11

ASKER

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

Avatar of leakim971
leakim971
Flag of Guadeloupe image

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

Open in new window

Avatar of Rob
Rob
Flag of Australia image

I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Avatar of leakim971
leakim971
Flag of Guadeloupe image

I think this one is answered
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo