Border appearing around a table row when it expands

I am working with a table that has multiple rows, and my goal is to make the border of a row extend over other rows when it is expanded. Refer to the image below for a visual representation. I am utilizing Bootstrap 5 and JQuery for this task. I have created an image to better illustrate what I am trying to achieve: https://i.sstatic.net/TvKJW.png

You can see how the border encompasses the individual items in the "T-Shirts" section. Here is the code snippet I am using:

$(document).ready(function() {
    $('tr:not(.header)').hide();
  
    $('tr.header').click(function() {
      $(this).find('span').text(function(_, value) {
        return value == '^' ? 'v' : '^'
      });
      
      $(this).nextUntil('tr.header').slideToggle(100, function() {});
    });
  });
tr.header {
  cursor: pointer;
}

input[type=checkbox]{
  /* Double-sized Checkboxes */
  transform: scale(1.20);
  padding: 10px;
}

.text-xs {
  font-size: 10px;
}

::-webkit-scrollbar {
  display: none;
}

table tr {
  border-spacing: 0 18px;
}

tr:not(.thead){
  border-radius: 10px;
}

tr:not(.header){
 transform: scale(0.90);
}

tr:not(.addButton):not(.header) {
  outline: 1px solid #0F6DFD;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

        <table class="table table-md table-borderless" id="table" style="width: 65%; color: #117AFF;">
          <thead>
            <tr class="header .thead">
              <th width="10%">NUMBER</th>
              <th>ITEM</th>
              <th></th>
              <th></th>
              <th width="20%">INFO</th>
              <th width="10%">INCLUDE</th>
            </tr>
          </thead>
          <tr class="header mt-3 shadow-sm">
            <th>042</th>
            <th colspan="3">T-Shirt</th>
            <th><span class="">v</span></th>
            <th><input class="form-check-input mx-auto d-block" type="checkbox" id="flexCheckDefault"></th>
          </tr>
          <tr class="pt-3 shadow-sm">
            <td class="align-middle col-1"><img src="img/bars-staggered-solid.svg" class="img-fluid w-25 mx-auto d-block"></td>
            <td class="align-middle col-1"><input class="form-check-input" type="checkbox" value="" id="flexCheckDefault"></td>
            <td class="align-middle col-8">Nike</td>
            <td class="align-middle col-6" colspan="2">   
              <div class="d-flex flex-column">
              <div class="text-xs">0 times, 0 times by Client</div>
              <div class="text-xs">0 times, 0 times by Client</div>
              <div class="text-xs">2 comments</div>
            </div>
          </td>
            <td class="align-middle"><i class="fa-regular fa-pen-to-square"></i></td>
          </tr>
          <tr class="pt-3 shadow-sm">
            <td class="align-middle col-1"><img src="img/bars-staggered-solid.svg" class="img-fluid w-25 mx-auto d-block"></td>
            <td class="align-middle col-1"><input class="form-check-input" type="checkbox" value="" id="flexCheckDefault"></td>
            <td class="align-middle col-8">Adidas</td>
            <td class="align-middle col-4" colspan="2">   
              <div class="d-flex flex-column">
              <div class="text-xs">0 times, 0 times by Client</div>
              <div class="text-xs">0 times, 0 times by Client</div>
              <div class="text-xs">2 comments</div>
            </div>
          </td>
            <td class="align-middle"><i class="fa-regular fa-pen-to-square"></i></td>
          </tr>
          <tr class="addButton">
            <td colspan="6" width="100%"><a href="#" class="btn btn-success fw-light" role="button" aria-disabled="true">Add new</a></td>
          </tr>
        </table>

Answer №1

Is this similar to what you had in mind?

I began by ensuring the table HTML was valid

$(document).ready(function() {
  $('tbody').hide();

  $('tr.header').click(function() {
    $(this).find('span').text(function(_, value) {
      return value == '^' ? 'v' : '^'
    });

    $('tbody').slideToggle(100, function() {});
  });
});
tr.header {
  cursor: pointer;
}

input[type=checkbox] {
  /* Double-sized Checkboxes */
  transform: scale(1.20);
  padding: 10px;
}

.text-xs {
  font-size: 10px;
}

::-webkit-scrollbar {
  display: none;
}

table tr {
  border-spacing: 0 18px;
}

tbody {
  border-radius: 10px;
  outline: 1px solid #0F6DFD;
}

tr:not(.thead) {
  border-radius: 10px;
}

tr:not(.header) {
  transform: scale(0.90);
}

tr:not(.addButton):not(.header) {
  outline: 1px solid #0F6DFD;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<table class="table table-md table-borderless" id="table" style="width: 65%; color: #117AFF;">
  <thead>
    <tr class="header .thead">
      <th width="10%">NUMBER</th>
      <th>ITEM</th>
      <th></th>
      <th></th>
      <th width="20%">INFO</th>
      <th width="10%">INCLUDE</th>
    </tr>
  </thead>
  <tbody class="pt-3 shadow-sm">
    <tr class="header mt-3 shadow-sm">
      <th>042</th>
      <th colspan="3">T-Shirt</th>
      <th><span class="">v</span></th>
      <th><input class="form-check-input mx-auto d-block" type="checkbox" id="flexCheckDefault"></th>
    </tr>
    <tr class="pt-3 shadow-sm">
      <td class="align-middle col-1"><img src="img/bars-staggered-solid.svg" class="img-fluid w-25 mx-auto d-block"></td>
      <td class="align-middle col-1"><input class="form-check-input" type="checkbox" value="" id="flexCheckDefault"></td>
      <td class="align-middle col-8">Nike</td>
      <td class="align-middle col-6" colspan="2">
        <div class="d-flex flex-column">
          <div class="text-xs">0 times, 0 times by Client</div>
          <div class="text-xs">0 times, 0 times by Client</div>
          <div class="text-xs">2 comments</div>
        </div>
      </td>
      <td class="align-middle"><i class="fa-regular fa-pen-to-square"></i></td>
    </tr>
    <tr class="pt-3 shadow-sm">
      <td class="align-middle col-1"><img src="img/bars-staggered-solid.svg" class="img-fluid w-25 mx-auto d-block"></td>
      <td class="align-middle col-1"><input class="form-check-input" type="checkbox" value="" id="flexCheckDefault"></td>
      <td class="align-middle col-8">Adidas</td>
      <td class="align-middle col-4" colspan="2">
        <div class="d-flex flex-column">
          <div class="text-xs">0 times, 0 times by Client</div>
          <div class="text-xs">0 times, 0 times by Client</div>
          <div class="text-xs">2 comments</div>
        </div>
      </td>
      <td class="align-middle"><i class="fa-regular fa-pen-to-square"></i></td>
    </tr>
    <tr class="addButton">
      <td colspan="6" width="100%"><a href="#" class="btn btn-success fw-light" role="button" aria-disabled="true">Add new</a></td>
    </tr>
  </tbody>
</table>

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

Slide your cursor over to reveal a picture

I'm looking to create an interactive image gallery where the user can hover over an image to reveal text below it. I've been trying to achieve this by setting up my images in a specific way: echo "<div class=textimage style=background-image:u ...

Server Error: Reactjs doesn't support posting images

I am experiencing an issue in my ReactJS project. When I attempt to upload an image using react-images-uploader, I encounter the following error: "Cannot POST /images error" Below is the code snippet for the image upload: <ImagesUploader ur ...

Using jQuery to dynamically update the content of a modal's body

I have a pair of buttons (Modal 1 & Modal 2) on my website. <!DOCTYPE html> <html lang="en"> <head> <title>Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=d ...

Unable to isolate segments of a string

Looking for a way to extract two different IDs from the following string: SPList:6E5F5E0D-0CA4-426C-A523-134BA33369D7?SPWeb:C5DD2ADA-E0C4-4971-961F-233789297FE9: using Javascript. The regular expression being used is : ^SPList\:(?:[0-9A-Za-z\-]+ ...

Could offering a Promise as a module's export be considered a legitimate approach for asynchronous initialization in a Node.js environment?

I am in the process of developing modules that will load data once and create an interface for accessing that data. I am interested in implementing asynchronous loading of the data, especially since my application already utilizes promises. Is it considere ...

Display dynamic form with database value on click event

Seeking assistance to create a JavaScript function or any other method to address the issue I am facing. Currently, I have a functional pop-up form and a table connected to a database with queries. The pop-up form successfully appears upon clicking, howeve ...

Click on the link in the modal to either download the image or view a larger version

Struggling to create a photo gallery similar to Google Photos because of large image sizes - around 15mb - causing slow loading for users with poor connections. Currently using a placeholder image while waiting for the full-size image to load, but encount ...

The tooltip of the Material UI IconButton is displaying incorrectly

Within my ReactJS application, I am utilizing Material UI along with react-bootstrap-table components. One particular cell in my application utilizes the Material UI IconButton as shown below: <IconButton tooltip={t('tooltips:editRegulation&apos ...

Ways to arrange objects to fill up space in a specific sequence

My HTML document contains two child HTML elements within the parent HTML. The parent HTML has a div with a class of .page, which is a large area for the children to occupy. Both children are of the same size and I need them to spawn in a specific order; fo ...

What are the steps for utilizing ReGex on a webpage?

Recently discovered Regex, so apologies if this is a beginner question, but I want to implement it on a webpage. I gave it a try, but it didn't work. Is there a specific library, SDK, or piece of code that I need to add? Here is the code I currently h ...

A guide on setting up ExpressJS Error Handling to display custom error messages based on the corresponding HTTP Status codes

I am struggling to figure out how to implement this task. You need to create an error on the /error path and pass it to the next function. Make sure to use appropriate error status codes for displaying different types of error messages. I attempted using ...

Increase the node size within dynatree

After reviewing the examples provided by the developers of dynatree, I noticed that by including "expand: true" in a node, it should appear expanded from the start. I decided to create a SQL query: Doctrine_Core::getTable('Folder') ...

Searching for two fields of an object in Angular using ng-repeat

Let's imagine we have this array $scope.myArr = [{ name: 'Marc Rasmussen', phone: 239470192, title: 'It Dude', description: 'Hello my name is Marc i am testing the fact that i can search for two fields in an o ...

Can you explain the distinction between Array() and [] in Javascript, and when would it be preferable to use one over the other?

Similar Question: Understanding the difference between "new Array()" and "[]" in JavaScript array declaration When working with JavaScript, you have the option to create a new array using: var arr = new Array(); or simply using: var arr2 = []; Wha ...

Exploring Entries in Several JSON Arrays

In my current project, I have successfully generated JSON using JSON-Simple. Query: I am seeking guidance on how to extract specific elements like "Sentiment," "score," and "review" from this JSON array. Although I have referred to a helpful resource he ...

Issue encountered while trying to download Jade through npm (npm install -g jade)

I am having trouble downloading jade via npm on my Mac (Yosemite). After downloading node and updating npm, I tried to install jade but encountered a series of errors that I cannot resolve. Even attempting to use sudo did not help, as it only displayed s ...

Creating a Vibrant Progress Bar with Multiple Colors: A Step-by-Step Guide

I'm still getting the hang of things, so I apologize if my question isn't perfectly clear. What I'm trying to do is create a dynamic progress bar with multiple colors that animates upon loading the page. I've seen some examples similar ...

Setting Up One Stylesheet Based on Local Preferences

I am working on positioning translated text on a webpage. The word NEW in English and NOUVEAU in French need to be centered below a graphic. Since the words have different lengths, I am considering using absolute positioning. The challenge is setting the l ...

Do external JavaScript files exclusively serve as repositories for functions?

Hey there, I'm a beginner in Web Development and I have a question that might sound silly: If I decide to keep my scripts in an external .js file, would it essentially just serve as a container for functions? For instance, if I attempt to include cod ...

Error message encountered when attempting to rotate an object in three.js: "Object is undefined"

Experiencing an "Undefined Object" error while attempting to rotate an object using three.js. Here is a snippet of the code in question: var object; function render() { renderer.render(scene, camera); } function animate() { object.rotation.x + ...