Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7747199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:28:12+00:00 2026-06-01T10:28:12+00:00

I have made a table row draggable with jQuery. It works as expected (mostly)

  • 0

I have made a table row draggable with jQuery. It works as expected (mostly) in Firefox and IE. However, in Chrome it resizes the original table for some reason.

<script type="text/javascript" src="js/jquery-1.7.1.min.js">
</script>
<script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js">
</script>

<script>
$(document).ready(function(){

    $(".drag").draggable({
        helper: function(event, ui){
            var ret = jQuery(this).clone();
            var width = jQuery(this)[0].offsetWidth;
            var myHelper = [];
            myHelper.push(
'<table style="width:' + width + 'px; background-color:green;">');
            myHelper.push(ret.html());
            myHelper.push('</table>');

            helper = myHelper.join('');
            return helper;
        },
        axis: 'y',
        revert: true,
        start: function(event, ui){
            event.target.style.backgroundColor = 'blue';
        },
        stop: function(event, ui){
            event.target.style.backgroundColor = 'red';
        }
    });
});

</script>

<html>

<table id="myTable" style="width:100%">
<tr class="drag">
<td> one </td>
<td> one </td>
<td> one </td>
<td> one </td>
<td> one </td>
</tr>

<tr class="drag">
<td> two </td>
<td> two </td>
<td> two </td>
<td> two </td>
<td> two </td>
</tr>

<tr class="drag">
<td> three </td>
<td> three </td>
<td> three </td>
<td> three </td>
<td> three </td>
</tr>

<tr class="drag">
<td> fourve </td>
<td> fourve </td>
<td> fourve </td>
<td> fourve </td>
<td> fourve </td>
</tr>

<tr class="drag">
<td> six </td>
<td> six </td>
<td> six </td>
<td> six </td>
<td> six </td>
</tr>
</table>
</html>

I also made this jsfiddle base on the previous code. In chrome it resizes the table. However, if I go to inspect the table, it snaps back as soon as I click it. What’s the deal Chrome? How do I keep it from resizing the table?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:28:14+00:00Added an answer on June 1, 2026 at 10:28 am

    Well, Andrew, according to the jQuery doc for draggable (options > appendTo),

    The element passed to or selected by the appendTo option will be used
    as the draggable helper’s container during dragging. By default, the
    helper is appended to the same container as the draggable.

    The problem, I theorize, is that your new table row is being added to the old table and Chrome is updating based on the width of that. Thus, if you set the appendTo option to a containing div, that will solve your problem! Here is the updated code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a table and contents some values, I have a button coding
I have a table that I've made sortable using the jQuery plugin Tablesorter 2.0
I have a table made up of thead and tbody elements. I have some
I have made a dump of my database in which one table is pretty
I have a trigger that stores changes made in a separate table when a
Hi I made this site a while ago in my table days but have
i have made columns in some of the tables encrypted in sql server 2008.
I have a table and for every row I would like to create a
I have a table where i can add some filters to the data being
Question for YUI experts... I have a table and I've made each cell of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.