How can I align a button right next to the table row data in HTML using Bootstrap?

Is there a way to add a button next to the table data in each row without a border? I attempted to create a new column for the button, but the border interferes with the design. I am using Bootstrap 4 for this project.

Here is the HTML code:

<div class="card-body col-10">
          <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
              <thead>
                <tr>
                  <th>Name</th>
                  <th>Email</th>
                  <th>Password</th>
                  <th>Phone</th>
                  <th>Privilege</th>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <th>Name</th>
                  <th>Email</th>
                  <th>Password</th>
                  <th>Phone</th>
                  <th>Privilege</th>
              </tfoot>
              <tbody>
                <tr>
                  <td>Tiger Nixon</td>
                  <td><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1f2d8d2d5c4cce1d8ced48fc2cecc">[email protected]</a></td>
                  <td>Edinburgh</td>
                  <td>081290188409</td>
                  <td>1</td>
                </tr>
                <tr>
                  <td>Tiger Nixon</td>
                  <td><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dc8fa5afa8b9b19ca5b3a9f2bfb3b1">[email protected]</a></td>
                  <td>Edinburgh</td>
                  <td>081290188409</td>
                  <td>1</td>
                </tr>
                <tr>
                  <td>Tiger Nixon</td>
                  <td><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1043696364757d50697f653e737f7d">[email protected]</a></td>
                  <td>Edinburgh</td>
                  <td>081290188409</td>
                  <td>1</td>
                </tr>
                <tr>
                  <td>Tiger Nixon</td>
                  <td><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4112383235242c01382e346f222e2c">[email protected]</a></td>
                  <td>Edinburgh</td>
                  <td>081290188409</td>
                  <td>1</td>
                </tr>
               
              </tbody>
            </table>
          </div>
        </div>

I am looking to position the button on the right side of the table next to the "Privilege" column. The button should not look like a table.

I experimented with incorporating the button as a table like in the code below:

<div class="card-body col-1">
    <div class="tablen float-left">
        <table class="table table-borderless" id="dataTable" width="100%" cellspacing="0">
            <thead>
                <tr>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><button type="button" class="btn btn-danger fas fa-table float-left"></button></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

However, the button appears too far from the table. I want to align it right next to the table. Any suggestions or solutions would be greatly appreciated. Thank you.

Answer №1

To accomplish this task with JQuery, you can follow these steps:

Alternatively, you could achieve the same result using CSS3 and the :before pseudo-element, but the exact syntax is unknown to me.

Below is the JQuery code snippet:

$("td").each(function (){
    $(this).append("<button type='button' class='btn btn-danger fas fa-table float-left'></button>" );
});

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

How to use JavaScript to retrieve extensive data streams (exceeding 1GB) from the internet

I'm interested in finding out if there is a way to stream data directly from JavaScript to the browser's download manager. With WebRTC, I am able to stream large amounts of data (files over 1GB) from one browser to another. On the receiving end, ...

What are the steps to incorporate @svgr/webpack into turbopack within a next.js project?

I'm encountering an issue with turbopack and @svgr/webpack in my project. According to the documentation, they should work together but it's not cooperating. When I run the project without using --turbo (turbopack), everything functions as expec ...

What is the method for inserting the document URL into a text input?

Can someone provide guidance on grabbing the top URL and inserting it into a text input field? I've tried the following method, but it's not working. Any suggestions or ideas? Additionally, is there a way to make this text input field uneditable? ...

The Nivo Slider is stealthily concealing my CSS Menu

Although this question has been previously asked, I am still unable to make it work with the solutions provided; The website in question is I have tried changing the z-index on all menu items to 99999, but they are still appearing below. <div id="sli ...

React, facing the challenge of preserving stored data in localStorage while accounting for the impact of useEffect upon

Seeking some assistance with the useEffect() hook in my Taking Notes App. I've set up two separate useEffects to ensure data persistence: one for when the page first loads or refreshes, and another for when a new note is added. I've added some l ...

Leveraging jQuery to Avoid Memory Leaks

After utilizing jQuery for a couple of months and delving into Javascript memory leaks for several days, I have two concerns related to memory leaks and jQuery: When I bind events (using .bind()) in jQuery, do I need to unbind them (.unbind()) before l ...

NodeJS hit with ECONNREFUSED error while trying to run localhost server

I currently have a NodeJS server running on my local machine, listening to port 50000. I am trying to make a simple GET request to this server from another local server, but I keep receiving an ECONNREFUSED error message: { Error: connect ECONNREFUSED 127 ...

Why is my code executing twice rather than just once?

` import './App.css'; import ArrayState from './components/ArrayState'; import FetchApi from './components/FetchAPI/FetchApi'; import Login from './components/Login'; import Useeffect2 from './components/Use ...

What is the best way to restrict users from accessing more than 5 Bootstrap Tab-Panes at once?

Users are restricted to opening only a maximum of 5 tab panes, even if there are multiple tab buttons available. If the user tries to click on the 6th tab, an alert message will be displayed. function addTab(title, url){ var tabs=$(".tabs"), tab ...

Upon clicking the navbar dropdown item, it shifts its position

I am currently working on setting up a navigation bar with multiple items aligned to the right side. However, I have encountered an issue where clicking on the "notification" icon causes the other icons in the navbar to move instead of remaining fixed in p ...

Creating a responsive layout with Bootstrap 4 by combining the card class within a d

In my attempt to align four cards side by side using the d-flex class, I have utilized the following code: <div id="home"> <div class="d-flex flex-row flex-wrap justify-content-between"> <div class="card"> <di ...

Guide on Creating a Popup Window When the User's Cursor Moves Beyond the Webpage Boundary

Imagine you're browsing a webpage and as you move your mouse towards the "back" button, a window pops up within the webpage area, displaying important information. This is a clever way to grab the user's attention before they leave the website. B ...

How can EJS variables be utilized within HTML input fields?

I am facing an issue while trying to use a checkbox to redirect selected users to a new page. I am looking for a solution on how this can be achieved, especially when using mongodb to store the information. Below is my current code snippet: Firstly, I ren ...

Identify certain lines from the paragraph text

Suppose you have an HTML Paragraph Element (e.g., <p>) with certain text sections highlighted using a HTML Mark Element (e.g., <mark>). I am interested in adding a vertical line in the margin or gutter (uncertain about the appropriate term) tha ...

Unable to retrieve context value for authentication requirements

I have implemented a feature in my application where I redirect users to the login page for certain special pages if they are not logged in. The implementation involves using react-router. Here is the code snippet for my RequireAuth component: const Requir ...

What is an alternative way to retrieve the page title when the document.title is unavailable?

Is there a way to retrieve the page title when document.title is not available? The code below seems to be the alternative: <title ng-bind="page.title()" class="ng-binding"></title> How can I use JavaScript to obtain the page title? ...

Create an HTML table with a static header, adjustable columns, and the ability to resize to a width smaller than the content

Looking to create a unique web application with a table that has a fixed, styled header, resizable columns, and the ability to resize the columns without truncating content. Additionally, I want the body of the table to scroll if it cannot all fit on the p ...

Exploring Vue JS: A guide to using the onChange event to dynamically update input values

I am currently utilizing the npm package vue-range-component to adjust values via a slider, which then dynamically updates in the input field. However, I'm encountering an issue with applying the onChange event for inputs. I need to have the ability ...

Trigger a click event in jQuery to activate a form through a hyperlink

I'm facing an issue where I want to implement a password-reset form based on a certain flag being triggered. Currently, my code is set up to prompt the user to change their password if the password_changed_flag is not present. Depending on the user&ap ...

Alter the hue within Google Chart

I'm working on customizing a Google Bar Chart with Material design and running into an issue with changing the background color. I've tried using backgroundColor and fill identifiers in the options, but the inner area of the chart where the data ...