TransWikia.com

Hiding table rows works, but fading out does not

Stack Overflow Asked by DiamondJoe12 on December 23, 2020

I was hoping to add a fade animation when hiding table rows.

This works:

$('#myTable > tbody > tr').not("[name*=" + thing + "]").hide()

This does not:

$('#myTable > tbody > tr').not("[name*=" + thing + "]").fadeOut("slow")

I’m using the full, uncompressed (non-slim version, I believe, of jQuery):

<script
  src="https://code.jquery.com/jquery-3.5.1.js"
  integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
  crossorigin="anonymous"></script>

One Answer

Since the element is "hidden", the jQuery selection won't work since that element isn't considered a child of the , from my understanding.

There's a few approaches mentioned in in-jquery-how-can-i-select-a-hidden-element*, particularly by Paolo Bergantino that would be useful here to make sure you can select the element.

For example, you may want to try something like this:

$("tr:hidden", "#mytable")...

Answered by mochsner on December 23, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP