Having trouble making the overflow feature work while scaling a <tr> element

I've been working on a table that has rows which can be animated to disappear. However, I've run into an issue where I can't shrink a row beyond the height of its content. Despite searching for solutions on Google and Stack Overflow, none of the suggestions have worked for me. I've tried using overflow: hidden; in my CSS, among other things.

You can view a working example here (apologies for not including the code directly, but it's easier to demonstrate through a live example). Click the button to create a new table and then click on the rows to make them disappear.

I know similar questions have been answered elsewhere, but those solutions haven't resolved my specific issue.

Any thoughts? I'm hoping to achieve complete shrinking of a clicked row before it is deleted.

PS.: Please excuse any lack of knowledge, as I am relatively new to web development.

PS2.: No jQuery solutions, please.

Answer №1

To update or change the line height, follow these steps:

https://jsfiddle.net/9hznp00s/12/

function deleteRow(id) {
    if (typeof (id) === 'undefined') return;

    var element = document.getElementById(id);

    // Set the row's height and opacity to 0 (the changes are animated by the CSS)

    // I commented this out so it's easier to see the collapse effect
    //element.style.opacity = 0;

    element.style.height = '0px';
    element.style.maxHeight = '0px';
    element.style.lineHeight = '0px';
    element.style.opacity=0.0;

    // After the animation is done, remove the row form the HTML
    setTimeout(function () {
        element.innerHTML = '';
        element.parentNode.removeChild(element);
    }, 500);
}

Alternatively, you can try one of these options:
https://jsfiddle.net/9hznp00s/8/

function deleteRow(id) {
    if (typeof (id) === 'undefined') return;

    var element = document.getElementById(id);

    // Set the row's height and opacity to 0 (the changes are animated by the CSS)

    // I commented this out so it's easier to see the collapse effect
    //element.style.opacity = 0;

    element.style.height = '0px';
    element.style.maxHeight = '0px';
    element.style.fontSize = '0px';

    // After the animation is done, remove the row form the HTML
    setTimeout(function () {
        element.innerHTML = '';
        element.parentNode.removeChild(element);
    }, 500);
}

https://jsfiddle.net/9hznp00s/10/

function deleteRow(id) {
    if (typeof (id) === 'undefined') return;

    var element = document.getElementById(id);

    // Set the row's height and opacity to 0 (the changes are animated by the CSS)

    // I commented this out so it's easier to see the collapse effect
    //element.style.opacity = 0;

    element.style.height = '0px';
    element.style.maxHeight = '0px';
    element.style.fontSize = '0px';
    element.style.opacity=0.0;

    // After the animation is done, remove the row form the HTML
    setTimeout(function () {
        element.innerHTML = '';
        element.parentNode.removeChild(element);
    }, 500);
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Stop Bootstrap form controls from displaying a focus glow when clicked

A virtual directory has been created where users have the ability to change file and directory names. Users can only edit names by double-clicking: <input type="text" class="form-control border-0 p-0 mb-1" ...

Trouble with Bootstrap 3's nav-justified feature not displaying correctly upon window expansion

Looking at this Bootstrap example page, I noticed a small issue with the nav-justified navigation. When the window is minimized, it transitions correctly to a mobile version. However, when the window is maximized again, the buttons remain in the mobile for ...

Retrieve an item from a table in VUE upon clicking

I am currently using Vue Bootstrap and I want to be able to access the item when a row in the table is clicked. I have set up a table and a clickmeRow method to handle the action on the clicked item. <b-table-lite hover :items="it ...

What is the best way to compare two arrays of data and make changes?

I am working with two arrays, array A and array B Here is how they look: A: [11, 14] B: [ { title: 'title 1', data: [ { node_id: 11, selected: false }, { node_id: 14, selected: false } ]}, { title: 'title 2', data: [ { node_id: 7 ...

Searching for a particular string, selector, or XPath on numerous web pages using the "inspect element" browser tool - what is the best approach?

Hey everyone, I hope you're all having a fantastic day. I'm wondering, is there a way to search for an element across multiple web pages simultaneously, rather than just one page at a time? The goal is to locate a specific string or code (like ...

Tips for managing the width of tr:nth-child(odd)

I am in search of a way to style my datasheets using tr:nth-child(odd). Below is the code snippet I am currently using: My main concern lies in adjusting the width. I aim for it to occupy a space that measures 200px by 400px The depth does not pose an is ...

There seems to be an issue with accessing the 'request' property of an undefined object

Currently, I am in the process of incorporating a base service into an Angular application. This service is designed to provide methods to other services for composing requests with default headers and options. However, I encounter an issue when attempting ...

Positioning images to the right without using the float property

In my WordPress website, I am using the NextGEN Gallery plugin to display fixed-width images within a fluid-width <aside>. My goal is to align these images to the right of the <aside> container without using the float property because it revers ...

Eliminate any blank brackets in a JSON structure

Looking to extract certain elements from a JSON string. Input : "sample": [{},{},{},{},{},{},{}], Output : "sample": [], Attempted solution : var jsonConfig = JSON.stringify(jsonObj); var result = jsonConfig.replace(/[{},]/g, ''); // Global ...

Using Jquery to increase input values in multiples on keyup event

Is there a way to ensure that an input element only accepts numbers in increments of 50? While we know we can use the step="50" attribute, is it possible to achieve this using the keyup event instead? I came across this code that restricts users from inp ...

What is the best way to incorporate a new field into an established JSON structure?

I have a JSON data set containing 10,000 unique records and I am looking to add another field with a distinct value to each record. What is the best way to achieve this? [ { _id: "5fffd08e62575323d40fca6f", wardName: "CIC", region: &quo ...

Executing an SQL delete query with a button click using a JavaScript function in PHP

I have created a setup with three essential files - index.html, database.php, and function.js. In database.php, there is a form generated containing a delete button that triggers the deletion SQL query when clicked. The primary objective is to present a ta ...

An error has been caught in the Angular JS application while using the highcharts-ng module: [$injector:modulerr]

I'm encountering an issue while trying to integrate Highcharts into my Angular/Node/Express application. I am utilizing the highcharts-ng directive available at https://github.com/pablojim/highcharts-ng Every time I run my app, I consistently receive ...

Making an element sticky within a container while the parent element is set to overflow hidden

Here is a case where I have generated HTML and CSS code that includes classes for overflow, container height, and sticky positioning: .overflow-hidden { overflow: hidden; } .overflow-x-auto { overflow-x: auto; } .container { max-height: 100px; ...

Node.js application with decoupled Redis client

In my node.js app, I am utilizing Redis for user caching. Once a user logs in, their information is cached and accessed on subsequent requests to determine their access level. This allows the client to receive personalized information and views based on th ...

Div behaving as a radio input

I have customized radio buttons to look like buttons using JavaScript. However, on page load, both buttons automatically receive the 'active' class instead of only when they are selected. Additionally, the fadeToggle function in the if-statement ...

Receiving an HTTP 405 Error? The Post method may function on one page but encounter issues on another (specifically with AJAX, Jquery, $.post

I'm facing a perplexing issue that has me puzzled. My website is currently hosted on IIS (in the testing phase, so everything is running through localhost). Using IIS 7.5 In my homepage (written in HTML), I have successfully implemented a PHP scrip ...

Place a two-column table within another column, but do so only after reaching a specific row within the data

I need to create a table with two columns of data, but I want to wrap it only after a specific row in the data set. For example, I may want to start wrapping from the middle or from a certain <tr>, like the one that contains <td>Here:</td> ...

What is the procedure for re-executing the request handler in a Node.js and Express application?

Currently, my setup involves node, express, and mongojs. Here is a code snippet that exemplifies my configuration: function mongoCallback(req, res) { "use strict"; return function (err, o) { if (err) { res.send(500, err.message); } else ...

Technique in CSS/SASS to repair a div

Seeking a solution for fixing divs with text in CSS. I am aware of the background-attachment: fixed; property which creates a fancy effect. Is there a similar property to "fix" divs with text or how can this be achieved in Typescript? Your insight would be ...