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

  • SEARCH
  • Home
  • 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 7679817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:58:02+00:00 2026-05-31T17:58:02+00:00

There are 2 tags whose positions I exchange if the Top is dragged and

  • 0

There are 2 tags whose positions I exchange if the Top is dragged and covers more than half the bottom . Initially, both theses are draggable. However, to exchange the positions, I exchange their innerHTML, and once this is done, both of them are no longer draggable. I’m fairly new to jQuery and any suggestions would be appreciated.

Heres, the code

Here’s part of the html

<div id="wrapper">
  <table id="panelTable" cellpadding="0" cellspacing="0">
      <tr id="panel_top_tr">
         <td id="panel_top_td" class="draggable">
            <div id="panel_top" class="panel">Panel Top</div>
         </td>
      </tr>
      <tr id="sep_tr">
         <td class="separator_horizontal"></td>
      </tr>
      <tr id="panel_bottom_tr">
         <td id="panel_bottom_td" class="draggable">
            <div id="panel_bottom" class="panel">Panel Bottom</div>
         </td>
      </tr>
  </table>
</div>

Theres is a bunch of html above and below this fragment, but you get the gist ..

Heres the jQuery code

$(function () {

        $_dropEnd = null;

        $(".draggable").draggable({
            axis: 'y',
            cursor: 'move',
            cancel: 'a',
            revert: 'invalid',
            snap: 'true',

            //store initial innerHTML values before dragging starts
            start: function () {
                table = document.getElementById("panelTable");
                row1 = document.getElementById("panel_top_tr");
                row2 = document.getElementById("sep_tr");
                row3 = document.getElementById("panel_bottom_tr");
                r1html = row1.innerHTML;
                r3html = row3.innerHTML;
            },

            //check position and exchange accordingly
            drag: function (event) {
                var headlineTop = $('#panel_top_td').position().top;
                var headlineHeight = $('#panel_top_td').height();
                var headlineBottom = headlineTop + headlineHeight;
                var headlineCenter = headlineTop + (headlineHeight / 2);

                var storyTop = $('#panel_bottom_td').position().top;
                var storyHeight = $('#panel_bottom_td').height();
                var storyBottom = storyTop + storyHeight;
                var storyCenter = storyTop + (storyHeight / 2);

                if (headlineBottom >= storyCenter) {
                    //Exchange                                               
                    row3.innerHTML = r1html;
                    row1.innerHTML = r3html;
                    isTop = false;
                    $('#panel_bottom_td').draggable('enable');
                    $('#panel_top_td').draggable('enable');
                }
            },
            stop: function (event, ui) {
                $(this).appendTo($_dropEnd);
                $_dropEnd = null;
            }
        });
    });
  • 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-05-31T17:58:03+00:00Added an answer on May 31, 2026 at 5:58 pm

    That’s a lot of code for a very easy task. I suggest you to look at jQuery UI Sortable, does exactly what you want, cross browser, easily configurable.

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

Sidebar

Related Questions

How to insert the ending html tags where there are missing ending tags ?
There is one client who cannot see the img title tags in IE8. Is
There is a website which is invalid XHTML (some closing tags are missing). I
There are lots of questions on how to strip html tags, but not many
Is there a way to specify pretty-print-like formatting around HTML tags? I want to
Is there any way to enclose <style> tags within <body> and still have valid
there are some code as this: <div class=test> <div class=upsell-tags> <?php echo $this->getChildHtml('product_additional_data') ?>
The new forms attributes and tags in HTML5 are great. Unfortunately, there is only
I have to get <p> and <br /> tags positions in whole html code.
Is there any way to get facebook's crappy Open Graph meta tags to validate

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.